Powershell - Where-Object Cmdlet
Advertisements
cmdlet
Where-Object cmdlet can be used to select objects having particular property values from the collection of objects that are passed to it.
In these examples, we're see the Where-Object cmdlet in action.
Example 1
Get stopped services.
Get-Service | Where-Object {$_.Status -eq "Stopped"}
Output
You can see following output in PowerShell console.
Status Name DisplayName ------ ---- ----------- Stopped AdobeFlashPlaye... Adobe Flash Player Update Service Stopped AeLookupSvc Application Experience
Example 2
Get processes based on process name.
Type the following command in PowerShell ISE Console
Get-Process | Where-Object {$_.ProcessName -Match "^p.*"}
Output
You can see following output in PowerShell console.
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName ------- ------ ----- ----- ----- ------ -- ----------- 62 7 1176 4992 61 0.03 7440 pageant
powershell_advanced_cmdlets.htm
Advertisements