Out-GridView

Send output to an interactive table in a separate window.

Syntax
      Out-GridView [-InputObject psobject] [-Title string] [-PassThru] [CommonParameters]
      Out-GridView [-InputObject psobject] [-Title string] [-Wait] [CommonParameters]
      Out-GridView [-InputObject psobject] [-Title string] [-OutputMode OutputModeOption] [CommonParameters]

Key
   -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.

   -OutputMode {None | Single | Multiple}
       Specifies the items that the interactive window sends down the pipeline as
       input to other commands. (Windows PowerShell 3.0+.)

       By default, this cmdlet does not generate any output.
       To send items from the interactive window down the pipeline, click to select
       the items and then click OK.

       The values of this parameter determine how many items you can send down the pipeline.

          None.       No items. This is the default value.
          Single.     Zero items or one item.
                      Use this value when the next command can take only one input object.
          Multiple.   Zero, one, or many items.
                      Use this value when the next command can take multiple input objects.
                      This value is equivalent to the -Passthru parameter.
        
   -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 Shift-click or Ctrl-click keys.
       By default, this cmdlet does not generate any output.
       This parameter is equivalent to using the Multiple value of the OutputMode parameter.

   -Wait
       Indicates that the cmdlet suppresses the command prompt and prevents Windows PowerShell
       from closing until the Out-GridView window is closed.
       By default, the command prompt returns when the Out-GridView window opens.

       This feature lets you use the Out-GridView cmdlets in Windows shortcuts.
       When Out-GridView is used in a shortcut without the Wait parameter, the Out-GridView
       window appears only momentarily before PowerShell closes.

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].

Examples

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

PS C:\> Get-Process | Out-GridView
or
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

Save cmdlet output in a variable then send it to Out-GridView:

($A = Get-ChildItem -Path $PSHOME -Recurse) | Out-GridView

Display the processes that are running on the Server64 computer in a grid view window:

Get-Process -ComputerName "Server01" | Out-GridView -Title "Processes - Server64"

Send data collected from remote computers to Out-GridView:

Invoke-Command -ComputerName S1, S2, S3 -ScriptBlock {Get-Culture} | Out-GridView

Select multiple processes from the Out-GridView window. The processes that you select are passed to the Export-CSV command and written to the ProcessLog.csv file:

Get-Process | Out-GridView -PassThru | Export-CSV -Path .\ProcessLog.csv

Use the -Wait parameter of Out-GridView to create a Windows shortcut to the Out-GridView window:

pwsh -Command "Get-Service | Out-GridView -Wait"

“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