How does ? {$_.Status -eq "Running"} work (PowerShell)?
In Powershell the question mark is an alias of Where-Object cmdlet:
The '?' symbol and Where are both aliases for Where-Object.
While $_
is the result/output from the pipeline as stated here
Contains the current object in the pipeline object. You can use this variable in commands that perform an action on every object or on selected objects in a pipeline.
To reduce the amount of characters, instead of typing
Get-Service | Where-Object {$_.Status -eq "Running"} | Select-Object -First 2 | Format-List
you can type using alias:
get-service | ? {$_.Status -eq "Running"} | select -first 2 | fl
or
gsv | ? {$_.Status -eq "Running"} | select -first 2 | fl