Send output to an interactive table in a separate window.

      Out-GridView [-InputObject psobject] [-Title string] [CommonParameters]

   -InputObject psobject
       Input object to be displayed

       If a collection of objects are specified, Out-GridView will treat
       the collection as one collection object, and will display one row
       that represents the entire collection.

       To display the each object in a collection, use a pipeline operator (|)
       to send objects to Out-GridView.

    -Title string
       The text that appears in the title bar of the Out-GridView window. 

       By default, the title bar displays the command that invokes Out-GridView.

    -passthru  (PowerShell 3.0)
       Adds an OK/Cancel button to the gridview allowing one or more items to be selected
       and returned back to the pipeline (select multiple items with the Ctrl key.

Standard Aliases for Out-GridView: ogv

Key features of Grid-View are: Resizable columns, proportionally spaced fonts and the ability to click on a column header to sort the entire grid by that column. Grouping and basic filtering are also available with a right click. To filter a particular column prefix the search with the column name e.g. status:stopped

To run the Out-GridView cmdlet requires .NET Framework 3.0, this should be available by default on Windows Vista or greater.

Selecting the columns to display

In most cases you can simply use Select-Object and pass a custom set of properties to Out-GridView through the pipeline:
some-cmdlet | Select-Object -Property property1, property2
| out-gridview

Select-Object will change the object type to a custom object, which may break things if you want to pipe the object further, from out-gridview onto other cmdlets. e.g. Allow the user to select an item which you then act upon.
A work-around for this limitation is to add a member to each object in the pipeline with a new Default Display Property Set [example].


Get the processes running on the local computer and sends them to a grid view window:

PS C:\> get-process | out-gridview
PS C:\> $p = get-process
PS C:\> $p | out-gridview

Display a formatted table in a grid view window:

PS C:\> get-process | select-object -property name, workingset, peakworkingset | sort-object -property workingset -de sc | out-gridview

“All truth passes through three stages. First, it is ridiculed. Second, it is violently opposed. Third, it is accepted as being self-evident” ~ Arthur Schopenhauer

Related PowerShell Cmdlets

Out-Default - Send output to default.
Out-Host - Send the pipelined output to the host.
Out-Null - Send output to null.
Out-Printer - Send the output to a printer.
Out-String - Send output to the pipleline as strings.
Tee-Object - Send input objects to two places.
Equivalent bash commands: redirection - Redirection and Process Substitution, cat > file2.txt – Redirect standard input into a file.

Copyright © 1999-2024 SS64.com
Some rights reserved