Recently, during the first meeting of our new south-german PowerShell Usergroup, Rolf Masuch showed us a nice feature which I didn´t know: Using Out-GridView as interactive filter.
Here is how to do it:
The magic parameter is –PassThru !
If you want the user to select, let´s say, some services to stop, you just can get the output of Out-GridView with the parameter PassThru:
$result = Get-Service | Out-GridView –PassThru
will show you a grid of all your services:
By filtering in the grid and pressing OK, you can select which services should land in $result:
$result now only holds the services that were in the filter in your grid:
Now you could use $result for stopping the user selected services
I think this is a nice little option if you have some interactive scripts.
Have a nice day!