查看-ExcludeProperty
Select-Object 中的选项:
Get-Process | `
Where-Object {$_.CPU -gt 0 } | `
Select-Object -Property * -ExcludeProperty $(Get-Process)[0].PSStandardMembers.DefaultDisplayPropertySet.ReferencedPropertyNames | `
sort -Descending | format-table
在哪里:
$(Get-Process)[0].PSStandardMembers.DefaultDisplayPropertySet).ReferencedPropertyNames
是Get-Process
输出中第一个返回值的默认列表。把整个事情分解:
# First process
$fp = $(Get-Process)[0]
# Standard Members
$PSS = $fp.PSStandardMembers
# Default Display Property Set
$DDPS = $PSS.DefaultDisplayPropertySet
# Names of those properties in a list, that you can pass to -ExcludeProperty
$Excl = $DDPS.ReferencedPropertyNames
$Excl
# Command using variables
Get-Process | `
Where-Object {$_.CPU -gt 0 } | `
Select-Object -Property * -ExcludeProperty $Excl | `
sort -Descending | format-table