Turn Out-GridView into Selection Dialog

by Sep 17, 2013

Finally, in PowerShell 3.0, Out-GridView can turn into a versatile selection dialog – just add the new parameter -PassThru and watch:

$Title = 'Select one or more files to open'

Get-ChildItem -Path $env:windir -Filter *.log |
  Out-GridView -PassThru -Title $title |
  ForEach-Object {
    notepad $_.FullName
  } 

You can basically pipe anything into Out-GridView. The user then can select part of the output, or filter the results with a keyword, then select one, some or all of the results. By clicking OK, the selected objects are then passed on to the next command.

Twitter This Tip! ReTweet this Tip!