Out-GridView: Go Ahead Make My Display!

When I first saw the Out-GridView cmdlet demonstrated, it just knocked my socks off. Here I am sitting in the very last row of a large auditorium with at least several hundred people, mostly software developers and test software developers, watching a long involved discussion of programming with Windows PowerShell.

In the middle of this discussion, the presenter said, "Oh, by the way, you can get a listing of all your assemblies easily displayed using the Out-Gridview cmdlet."

And then, this fully searchable window with a list of assemblies popped up. This was displayed in a separate window that looked like a spreadsheet. A spreadsheet that you didn't have to do much work to setup the display!!

This is a whole lot less work than writing directly to an Excel spreadsheet or creating a CSV (comma separated variable) file and then importing into Excel.

All this from one single line of code.

I saw an immediate response from the audience. Everyone leaned forward fully-engaged. This had totally gotten everyone's attention.

This was just so cool and yet, the way it was presented was so ho-hum. Since the team had first blogged about the Out-GridView cmdlet in December of 2007, a whole year before this presentation, I guess to them it was already old news. But I wanted to jump up and down shouting "Yay!!" I could see just so many uses for this cmdlet.

And the name of this cmdlet doesn't fully express to me just how useful this cmdlet is. I'll look into all the ins and outs of this as I go through this in gory detail. But as far as I could see, this really should have been named something like, "Out-PoorPerson'sSpreadSheetView" or something like that. Because this cmdlet can be used that way.

So, I wondered how many different ways I could use Out-GridView. I first tried the easiest cmdlet I could use with Out-GridView. I combined it with Get-Help.

Now, I'm one of those people who likes to 'read the manual' when I start playing with new software. And with Windows PowerShell, your basic help comes with the programming language through the use of the Get-Help cmdlet. Now, I can get a summary of all the available help topics on the command line when I run:

Get-Help *

And when I scroll through the results, I get some idea of what these topics cover, but unfortunately in a normally sized window, the text runs off the screen in some cases.

 

And if I want to look at all the topics, I need to scroll up and down. It would be nice to be able to resize the window without having to redisplay the information to see more of it. It would also be nice to be able to search the information in the display for specific topics. And of course, it would be nice if I could rearrange the information the way I want, even if I change my mind about it.

And when I pipe the output of the Get-Help * cmdlet to the Out-GridView cmdlet, I can now get exactly that type of display using one line of code:

Get-Help * | Out-GridView

Where the | represents the pipe operation

Here's what the display for Get-Help * looks like displayed using the Out-GridView cmdlet.

 

You have to admit it looks like a spreadsheet. And if I forgot what I ran, the title reminds me of exactly what was run.

And it was that easy. What's amazing is that this window is fully searchable and I can rearrange the data to suit how I want to look at it.

I’ll take a closer look at this window and everything I can do with it starting with the next blog post.

Comments

  • Anonymous
    January 01, 2003
    The comment has been removed
  • Anonymous
    July 15, 2010
    I adore your site, looks excellent and full of good info. Keep it up.