Out-GridView: Where does Out-GridView get the column headers?

While I was reading the help for the Out-GridView cmdlet, I started wondering where the column titles came from. And as happens with Windows PowerShell, asking myself one question leads to another and another. I find that my mind goes down the question habit trail that leads to the hamster wheel and I cycle through a number of questions over and over again in an endless manner. I cycle until I realize there's many levels of answers and the easiest way to think about some things in Windows PowerShell is to first take the simplest answer and then decide if I want to go any further with the explanations.

So, I went back to the help for the Out-GridView cmdlet. I ran:

Get-Help Out-GridView

The first line of the detailed description gave me the best clue to the simplest answer to my question of how does Out-GridView figure out what column headings to use. The line I'm referring to states, "The Out-GridView cmdlet sends the output from a command to a grid view window..." (Obviously, there's more to the help for Out-GridView. While it's all worthwhile reading, my goal is just to highlight this specific nugget of information.)

What does sending the output from a command to a grid view window mean with regards to the column headings?

I picked two examples that everyone uses to illustrate the meaning for myself. At it's simplest level, I ran the Get-Help * and the Get-Process cmdlets in the Windows PowerShell directly and then with the output piped to the Out-GridView cmdlet. And here's what I found.

Example 1: Get-Help *

Running Get-Help * cmdlet directly in Windows PowerShell displays three columns with headings called: Name, Category, and Synopsis. In the below picture, I've scrolled back to the beginning of the output so I can see the headings.

And now compare this to the separate window created when I pipe the output from Get-Help * into the Out-GridView cmdlet (Get-Help * | Out-GridView).

Notice the column headers are the same as the ones printed in Windows PowerShell when I ran Get-Help * as in the first picture.

Example 2: Get-Process

It sometimes helps me to repeat the experiment with a different cmdlet just to make sure the first try wasn't a fluke. I'm going to compare the output of the Get-Process cmdlet with the column headings in the grid view window when I pipe the output from the Get-Process cmdlet to the Out-GridView cmdlet.

And to save space in this blog post, this time I'll just show the column headings this time.

Here's the headings I see when I run Get-Process in Windows PowerShell:

And here's the headings for the grid view window when I've piped the output from Get-Process to Out-GridView, in other words, Get-Process | Out-GridView.

With the pictures scoped down to just so the headings, it is pretty obvious they are the same.

An off the topic, BTW here... Notice, that for Get-Process I ran ps. This is known as an alias. An alias lets you use a shorthand instead of always typing out the full cmdlet name. For more information take a look at the about_Aliases topic on Technet or type the following in Windows PowerShell.

 get-help about_Aliases

Now, the next question I have is still where do these column headings come from, in other words, they represent something about the output of the cmdlet. But what is that?

Do I need to know this in order to use the Out-GridView cmdlet to analyze information I'm getting from other cmdlets? I would say, no, I can use these cmdlets with what I now know.

Next post I plan to walk through more examples showing different aspects of the Out-GridView cmdlet and how it comes in handy for things like analyzing event logs. A pretty nice feature of using Out-GridView.

Or, I can follow down the question habit trail of what these column headers represent. In other words, I would ask, "Tell me about Windows PowerShell objects and how understanding this will help me do more with the output of cmdlets?"

If you prefer one topic over the other, let me know and I can shift to following down the trail of thought to look at objects. Just want to avoid that squeaky old hamster wheel....

So, till next post, try out some of your own cmdlets with Out-GridView. Post comments on things you've tried and what you want to talk about next. And thanks for listening.  --- Judith Herman