Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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'})}