PowerShell Pop-Out Grid Output

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.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish