How to filter the output from the output of this powershell command?

munish
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

Martin Brandl

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How can I filter output of my command? (Powershell)

How to filter the output in powershell for class

How to filter a part of an output in powershell

How to indent command output in powershell

How to filter output lines from bash command based on directorys

How to get original binary data from external command output in PowerShell?

How to create a variable from specific part of command output in powershell script

Powershell live output from an external command

Suppress output from Git command in PowerShell

No output from cmd command calling powershell

powershell get content from command output

Selecting multiple strings from the output of command in powershell

Capturing output from Powershell command and saving it in a variable

How to filter specific details in an output Powershell

Filter Powershell Output

Filter output of command by color

Filter the output of find command

How to get the output of a powershell command into an array

How to define a command alias in PowerShell for filtering output?

How to use output file in another powershell command?

Formatting command output in Powershell

How to output html from filter inside mustache

How to filter output lines from bash command, based on dates in start of the line?

Powershell: gci filter with compact output

Powershell filter output data from Get-WinEvent

Powershell: Filter out specific value from custom output of a program

I want to filter data from output in powershell script

Powershell: How can I avoid counting enters (blanked line) of output from a command?

how to output date and time from powershell to a file