Chirag Nagrekar has Published 465 Answers

How to sort the output in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 07-Apr-2020 12:25:24

To sort the output in the PowerShell you need to use Sort-Object Pipeline cmdlet. In the below example, we will retrieve the output from the Get-Process command and we will sort the, according to memory and CPU usage.ExampleGet-Process | Sort-Object WorkingSet | Select -First 10OutputHandles  NPM(K)    PM(K)     ... Read More

How to use Measure-Object in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 07-Apr-2020 12:21:33

Measure-Object in PowerShell is used to measure the property of the command. There are various measurement parameters are available. For example, Average, Count, sum, maximum, minimum and more.ExampleGet-Process | Measure-ObjectOutputPS C:\WINDOWS\system32> Get-Process | Measure-Object Count       : 278 Average     : Sum         : ... Read More

How to use Group-Object cmdlet in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 07-Apr-2020 12:18:10

As the name suggests, Group-Object is useful to group similar properties.ExampleGet-Service | Group-Object StatusOutputCount Name          Group ----- ----          ----- 160 Stopped         {AarSvc_8f3023, AdobeFlashPlayerUpdateSvc, AJR outer, ALG...} 130 Running         {AdobeARMservice, Appinfo, AudioEndpointBuilder, Audiosrv...}The above output ... Read More

How to check the PowerShell version installed in local and remote systems?

Chirag Nagrekar

Chirag Nagrekar

Updated on 07-Apr-2020 11:58:36

To check the PowerShell version installed in your system, you can use either $PSVersionTable or $host command.Check if $host command available in remote servers.Open the PowerShell console in the system and run the command $PSVersionTable.$PSVersionTableOutputPS C:\WINDOWS\system32> $PSVersionTable Name                         ... Read More

How to edit the CSV file using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 26-Mar-2020 07:32:48

To edit the CSV file using PowerShell, you need to use the below commands.We already have the CSV file output.csv, we will import this file first.$csvfile = Import-csv C:\temp\Outfile.csvOutputBelow is the output of the CSV file.EMP_Name    EMP_ID     CITY --------    ------     ---- Charles     ... Read More

How to append data into a CSV file using PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 26-Mar-2020 07:28:05

To append the data into CSV file you need to use –Append parameter while exporting to the CSV file.In the below example, we have created a CSV fileExample$outfile = "C:\temp\Outfile.csv" $newcsv = {} | Select "EMP_Name", "EMP_ID", "CITY" | Export-Csv $outfile $csvfile = Import-Csv $outfile $csvfile.Emp_Name = "Charles" $csvfile.EMP_ID = "2000" ... Read More

How to create a CSV file manually in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 26-Mar-2020 07:23:52

There are few methods to create a CSV file in the PowerShell, but we will use the best easy method to create it.First, to create a CSV file in PowerShell, we need to create headers for it. But before it, we need output file name along with its path.$outfile = ... Read More

How to Export and import CSV file manually in PowerShell?

Chirag Nagrekar

Chirag Nagrekar

Updated on 26-Mar-2020 07:19:32

When you run a command Export-Csv in PowerShell, it automatically creates a CSV file to the specific location.ExampleGet-Service | Select Name, Starttype, Status | Export-Csv C:\temp\services.csv -NoTypeInformationIn the above example, Services.csv file created in C:\Temp folders with the header Name, Starttype, and Status headers.Similarly, you can use the other commands ... Read More

How to use custom headers in the PowerShell output table?

Chirag Nagrekar

Chirag Nagrekar

Updated on 26-Mar-2020 07:07:34

If you want the specific properties in PowerShell, you need to use the Select-Object (Alias − Select) as a pipeline.In the below example, we will retrieve the specific properties of the Spooler service.ExampleGet-Service Spooler | Select Name, DisplayName, Starttype, StatusOutputName       DisplayName    StartType    Status ----   ... Read More

Explain output formatting PowerShell

Chirag Nagrekar

Chirag Nagrekar

Updated on 26-Mar-2020 07:03:15

In PowerShell, the output is in the default table format. To format the output in the desired format, mainly below pipeline commands are used.Format-TableFormat-ListFormat-WideThere are also commands to format the output data but not used widely.Format-CustomFormat-HexIn the below example, we will get the service's details using Get-Service and format it ... Read More

Advertisements