Filtering
PowerShell

When you get a lot of info and you are only interested in specific values then filtering may be the way to go.

Let's say you need a list all eventlogs that are in the applicationlog and only those who EventID is 1001

Get-EventLog | Where-Object { $_.EventID -eq "1001" }

Okay let's make it a little harder and find all the processes that are set on automatically but are not running?:

Get-WmiObject Win32_Service |? {($_.Started -eq $false) -and ($_.StartMode -eq "Auto")} | Format-Table

Or even faster
Get-WmiObject -query "select * from win32_Service where `Started=false and StartMode='Auto'" | Format-Table

On Me

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License