PowerShell06- PowerShell result display options

PowerShell developers needs to analyze the commands and results many a time, it is good to know how the results can be formatted for better visibility. I will share few examples which can be used for reference…

• Get-Process | Format-Table -Property name, handles, vm, ws
Format-Table option helps to show results in table structure, required columns can be selected with -Property option.

• Get-Service | Format-Table -property name, status, displayname -AutoSize
AutoSize option can be used to allow PowerShell to adjust the display size of the columns.

• Get-Service | Format-Table -property name, status, displayname -AutoSize -wrap
wrap option does not truncate the text due to column size but results will be displayed in next line.

• Get-Process | Format-List -Property *
Format-List displays the results line by line

• Get-EventLog application -N 5 | Fl s*,e* #(Choosing propery by wiledcard)
Format-List can also let you decide the column(Property) names using wildcard

• Get-Process | Format-list m* | more
more option is something I use very often when expected results are displayed in multiple pages. More option will display one page at a time.

• Get-Process | Format-Wide -Property name
• Get-Process | Format-Wide -Property name -Autosize
• Get-Process | Format-Wide -Column 4
Format-Wide can be used to display single column values in multiple columns in a single page

• gps | Out-GridView
# ○ Sorting
# ○ Filtering
Out-GridView pops out the results in a different window, the same window can be used for sorting and filtering results.

• gps > d:\gpsresults.txt
• gps >> d:\gpsresults.txt
>, >> These symbols are used to redirect the results to output file. >> symbol appends the results into the file but > symbol deletes the content and inserts results.

Get-Process | Format-Table -Property name, handles, vm, ws
Get-Service | Format-Table -property name, status, displayname -AutoSize
Get-Service | Format-Table -property name, status, displayname -AutoSize -wrap
Get-Process | Format-List -Property *
Get-EventLog application -N 5 | Fl s*,e* #(Choosing propery by wiledcard)
Get-Process | Format-Wide -Property name
Get-Process | Format-Wide -Property name -Autosize
Get-Process | Format-list m* | more
Get-Process | Format-Wide -Column 4
gps | Out-GridView
#	○ Sorting
#	○ Filtering
gps > d:\gpsresults.txt
gps >> d:\gpsresults.txt
Advertisements
This entry was posted in Learn_Powershell, Powershell and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s