# List all processes
Get-Process
# Display 70 dashes so it makes a line
# (This makes it easier to see different output)
Write-Host $('-' * 70)
# Show only SQL processes
Get-Process -Name *sql*
# Dashes
Write-Host $('-' * 70)
# Looks pretty much the same but with column headers
Get-Process -Name *sql* | Format-Table
# Unfortunately this truncates the output
Get-Process -Name *sql* | Format-Table -Property Path, Name, Id, Company
# Better because we can now see the Path but depending on console size Company is still truncated
Get-Process -Name *sql* | Format-Table -Property Path, Name, Id, Company -AutoSize
# Wraps output so we can see everything
Get-Process -Name *sql* | Format-Table -Wrap -Property Path, Name, Id, Company
# Groups all processes by Company
Get-Process | Format-Table -Wrap -AutoSize -Property Path, Name, Id -GroupBy Company | more
# Displays all processes in wide format.
# Format-Wide only displays the default property by default.
# The net result is that this shows us each process in a multi column list.
Get-Process | Format-Wide
# Shows us the same thing. I guess Name is the default property.
Get-Process | Format-Wide -Property Name
# Still a multi-column list but this time company names.
Get-Process | Format-Wide -Property Company
# Shows each process with one line per property
Get-Process | Format-List
# Creates an array of processes
$processes = Get-Process
# Displays the fifth process in the array
$processes[4]
# Dashes
Write-Host $('-' * 70)
# Alias for Format-List
Get-Process | fl
# Alias for Format-Wide
Get-Process | fw
# Alias for Format-Table
Get-Process | ft
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.