The PowerShell Out-GridView cmdlet

There's a PowerShell cmdlet that I've seen before, but it's never quite lodged itself in my brain sufficiently for me to remember it and use it. It's Out-GridView and it's something that won't be of any use to you if you're running a Server Core installation, but if you've got GUI, you're good to go.

Running this: (yes, I know, 'dir' alias, yuk, etc!)

dir | Out-GridView -Title "Directory Contents"

Gives you this:

That's just a little bit cool, but it's a GUI, so what's so useful about it? Well,..... There's the "Filter" text box and the "Add Criteria" drop-down button. Anything you type into the "Filter" text box will be used to match, so type in "www" and everything except the last item will disappear. Type in "21:" and everything will stay visible - two have 21 as the hour, the other has it as the minute. Type in "21:37" and we'll say goodbye to "local.robertwray.co.uk". The "Add Criteria" drop-down button lets you build up complex, well, queries pretty much, like this one:

Once you've done all this, you can (as it's PowerShell) pipe the output to something else - like a CSV file (based on one of the examples in the linked docs.microsoft.com documentation):

dir | Out-GridView -Title "Directory Contents" -PassThru | Export-Csv -Path .\DirectoryList.csv

About Rob

I've been interested in computing since the day my Dad purchased his first business PC (an Amstrad PC 1640 for anyone interested) which introduced me to MS-DOS batch programming and BASIC.

My skillset has matured somewhat since then, which you'll probably see from the posts here. You can read a bit more about me on the about page of the site, or check out some of the other posts on my areas of interest.

No Comments