Get-WinEvent -FilterHashTable @{LogName="Microsoft-Windows-PrintService/Operational";} |
Format-Table -Property TimeCreated,
@{label='UserName';expression={$_.properties[2].value}},
@{label='ComputerName';expression={$_.properties[3].value}},
@{label='PrinterName';expression={$_.properties[4].value}},
@{label='PrintSize';expression={$_.properties[6].value}},
@{label='Pages';expression={$_.properties[7].value}}
我想从上述命令的输出中过滤掉PrinterName为“ MyPrinter”的所有行
答案 0 :(得分:3)
只需在格式化表格之前添加一个Where-Object
条件:
Get-WinEvent -FilterHashTable @{LogName="Security";} |
Where-Object { $_.properties[4].value -eq 'MyPrinter'} |
Format-Table -Property TimeCreated,
@{label='UserName';expression={$_.properties[2].value}},
@{label='ComputerName';expression={$_.properties[3].value}},
@{label='PrinterName';expression={$_.properties[4].value}},
@{label='PrintSize';expression={$_.properties[6].value}},
@{label='Pages';expression={$_.properties[7].value}}