Using List View in a Grid View Window (Part 1)

by Jan 23, 2018

One of the simplest hardware inventories is probably this line:

$data = systeminfo.exe /FO CSV | ConvertFrom-Csv
$data | Out-GridView

A more modern approach uses the new cmdlet Get-ComputerInfo:

$data = Get-ComputerInfo
$data | Out-GridView

One simple approach is a hash table that is created for you by Group-Object: group the original data by a property like “UserName”. Then, show the hash table keys in the grid view window. Once the user selected an item, use the selection as key to the original item in your hash table:

$data = Get-ComputerInfo
$data | 
  Get-Member -MemberType *Property | 
  Select-Object -ExpandProperty Name |
  ForEach-Object { $hash = @{}} { $hash[$_] = $data.$_ } { $hash } |

Now the grid view window displays the information in a much better way. The code simply used Get-Member to find out the property names exposed by the information object in $data. It then created a hash table where each property was a key, and each value the property value.

In essence, the grid view window now shows a hash table with its multiple key-value pairs instead of one single object.

Are you an experienced professional PowerShell user? Then learning from default course work isn’t your thing. Consider learning the tricks of the trade from one another! Meet the most creative and sophisticated fellow PowerShellers, along with Microsoft PowerShell team members and PowerShell inventor Jeffrey Snover. Attend this year’s PowerShell Conference EU, taking place April 17-20 in Hanover, Germany, for the leading edge. 35 international top speakers, 80 sessions, and security workshops are waiting for you, including two exciting evening events. The conference is limited to 300 delegates. More details at

Twitter This Tip! ReTweet this Tip!