Tag: PowerShell

How to monitor new lines in a file in PowerShell

How to set up notifications for new lines in a file If you need to monitor logs (journals) in which new lines appear, then Windows has a convenient tool for this. You do not need to install or configure anything additionally – everything you need is already available on all current versions of Windows. You can monitor the appearance of...

How to read file contents in PowerShell. How to save file contents to a variable

Table of contents How to read file contents and display them on the screen How to read a file and save it to a variable How to read multiple files with a single Get-Content command Using wildcards with file names in Get-Content How to read a specified number of lines from the beginning of a file How to read a...

Analogs of cat, tail, head and wc in PowerShell

How to pass the contents of a file to a cmdlet in PowerShell In this article, we will look at how to get the contents of a file and send it to a cmdlet for processing or for display on the screen. In Bash on Linux, when you need to pass data from a file, commands either work with standard...

How to assign cmdlet output to a variable and How to use a variable with saved output

Table of contents How to save cmdlet output to a variable How to display the contents of a variable in Terminal How to process the contents of a variable using a cmdlet How to count the number of rows in a variable How to get an idea of ​​the contents of a variable without printing the entire results How to...

How to determine an object's type in PowerShell

Table of contents 1. How to determine an Object's type in PowerShell 2. Determining the object type with .GetType() (as well as .GetType().Name and .GetType().FullName 3. How to get the object type with Get-Member 4. Checking object types with the -is and -isnot type operators 5. How to check the type of collection elements 6. The .GetType().IsArray property to test...

How to display the full user name in a domain and workstation in PowerShell and CMD

Contents 1. How to find the full name of a user on the local computer 1.1 net user $env:USERNAME 1.2 Get-WMIObject Win32_UserAccount 1.3 [adsi] 1.4 Displaying the user name in CMD 1.5 Full user name in the Windows registry 2. How to get the current Windows user display name from the command line (for computers that are part of a domain) 2.1...

PowerShell: how to find only folders with Get-ChildItem

This post will show you how to list only folders and subfolders of a specific directory in PowerShell. We will use the Get-ChildItem cmdlet, which shows the children of a selected drive or directory. How to list only folders in Get-ChildItem To list only folders without files in PowerShell, use the Get-ChildItem cmdlet with the -Directory option. For example, the...

How to find large files in PowerShell (using Get-Childitem)

This tutorial will tell you how to find large files (more than 2GB, 3GB, 10GB, or any other size). And also how to list large files in PowerShell. To find files, we will use the Get-Childitem cmdlet. This cmdlet gets elements and child elements in one or more specified locations. The description of the cmdlet is quite convoluted – the...

Hashtables in PowerShell (strings that start with @) (complete guide)

Table of Contents 1. What are Hashtables in PowerShell 2. What are hashtables used for? 1) Storing data 2) Cmdlet options 3) Formatting output 4) Converting to JSON 3. Syntax for creating hashtables 4. Why the order of keys is not maintained in the hashtable. How to create an ordered hashtable 5. How to output the contents of a hashtable...

An analogue of cd and chdir in PowerShell. How to change the current working folder in PowerShell

Why change the working folder in the command line The current folder (or working folder) is the location in the file system where the user is located when working in the Terminal. Strictly speaking, each running process has its own working folder (at startup, it coincides with the folder where the file or script that launched this process is located,...
Loading...
X