PowerShell: One Liner to fetch running services
Scenario
Need to write PowerShell one-liner to fetch running services.
Assessment
help Measure-Command -Examples help Get-Service -Full |
Code with Pipeline
Get-Service | ? {$_.Status -like 'Running'}
PowerShell 4.0 Optimal Way with No Pipeline
(Get-Service).Where({$_.Status -like 'Running'})
Now try this
Measure-Command { Get-Service | ? {$_.Status -like 'Running'} }
Measure-Command { (Get-Service).Where({$_.Status -like 'Running'})}