1
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}} 

I want to filter out all those lines where PrinterName is "MyPrinter" from the output of the above command

0

1 Answer 1

3

Just add a Where-Object condition before you format the table:

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}} 
Sign up to request clarification or add additional context in comments.

2 Comments

I think you want $_.properties[4].value -ne 'MyPrinter'
@AdminOfThings You might be right. munish just adopt the operator to your need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.