PowerShell Pop-Out Grid Output

Here's how to display a pop-up window of PowerShell code in a formatted grid output, to easily show information or even to let users select items.

John Savill

July 19, 2013

1 Min Read
PowerShell Pop-Out Grid Output

Q: How can I easily display a pop-up of the output of Windows PowerShell in a grid dialog box and allow users to select items for the next action?

A: Sometimes from a PowerShell script it's very useful to display a pop-up window in a formatted grid output, to easily show information or even to let users select items.

This is easily achieved with the Out-Grid cmdlet. For example, to display a list of all virtual machines (VMs) I could use:

Get-VM -ComputerName Savdalhv01 | Out-GridView

This displays the following output:

By adding -PassThru to the Out-GridView, the user could select one or more VMs, and then those VMs would be passed to the next command in the pipeline. For example, you could use the command sequence with a Live Migration:

Get-VM -ComputerName Savdalhv01 | Out-GridView -PassThru | Move-VM -DestinationHost Savdalhv02 -DestinationStoragePath D:Virtuals

You can further tailor the output, such as by using the Title parameter for Out-GridView to change the title of the displayed dialog box.

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like