How out-gridview selection works in PowerShell?


With the PowerShell Out-Gridview output, you have an option to select one or multiple selections.

For example, if we run the below command, it will show us the output in the grid format.

PS C:\> Get-Process | Out-GridView

In this output, you don’t get any option to select the rows because its output mode is none. To add the single selection from the output, use the Output mode to single, and for the multiple selections use the output mode to multiple. Once you add the OutpuMode property you can see the OK and Cancel button at the bottom right of the grid.

Single output mode −

PS C:\> Get-Process | Out-GridView -OutputMode Single

We will select cmd and press ok.

NPM(K) PM(M) WS(M) CPU(s) Id    SI ProcessName
------ ----- ----- ------ ----- -- -----------
5      2.36  17.58 0.22   26096 1  cmd

Multiple selections,

PS C:\> Get-Process | Out-GridView -OutputMode Multiple
NPM(K) PM(M) WS(M) CPU(s) Id SI ProcessName
------ ----- ----- ------ ----- -- -----------
5      2.36  17.42 0.22   26096 1 cmd
41     20.99 7.89  29.95  24040 1 AcroRd32

Updated on: 01-Sep-2021

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements