Friday Fun: View Objects in a PowerShell GridList

One of the things that makes PowerShell easy to learn is discoverability. Want to know more about a particular type of object? Pipe it to Get-Member. Or if you want to see values pipe it to Select-Object.

That’s not too bad. Or you can pipe to Out-Gridview.

However, for a single object it isn’t easy to see everything .

What would be easier, at least for me, is to use Out-Gridview but see the properties in a list like I can with Select-Object. So I wrote an advanced function to do just that. The function takes an incoming object, creates a hashtable based on the object’s properties and then displays the hashtable in Out-Gridview.

The function will accept multiple objects, which is why I have a data array to handle multiple piped in objects. But it really works best with a single object. In the Process scriptblock I pass the object to Get-Member to retrieve properties. Then the function creates a hashtable where the key is each property and the value is the corresponding value from the object.

At this point I could simple write the hashtable to Out-Gridview, but the column headings would say Name and Value. It’s a small detail but I use a hashtable with Select-Object to rename “Name” to “Property”. By the way, you may have noticed this line.

That isn’t a typo. If I pipe multiple objects, then $data will be an array of hashtables and so I need to get an enumerator for each one. But with this function now I get the display I want.


There really isn’t any filtering to do but you can click on the column headings to sort. Or your can run Out-Gridlist with -passthru so you can select properties and pass them through to the pipeline.

I hope you find this useful. Enjoy responsibly.

6 Replies to “Friday Fun: View Objects in a PowerShell GridList”

  1. I am still on Ver 2
    I have tried changeing the (Position=0, to Position = 0 but no luck. I still get this error.

    The “=” operator is missing after a named argument.
    At line:4 char:35
    + [Parameter(Position = 0,Mandatory, <<<< ValueFromPipeline)]

    1. In v2 you have to assign a value to Mandatory and ValueFromPipeline: Mandatory=$True,ValueFromPipeline=$True

  2. Jeff, a question my friend. You told “The function will accept multiple objects, which is why I have a data array to handle multiple piped in objects.”.
    You are meaning by pipeline right ? Otherwise the $InputObject parameter need to be [Object[]] right ?
    Thanks Sir

    1. Yes. As written, if I tried this: out-gridlist -input $stuff it would only process the first object. But since this is an OUT command I didn’t bother.

Comments are closed.