Sending multiple command outputs to a single Out-GridView

I’ll admit – I’ve been very remiss in keeping this up of late. To make up for that I’m going to try to make sure to do three posts a week.

Since it’s now right at 2155 I won’t be able to do anything continuing my previous posts. However, I will provide a handy tip.

Frequently I have come across needing to get information from several accounts and put them into a spreadsheet. Often there isn’t sufficient need to build a huge script to set things up, so what I do is this.

I start with and array type variable and add my first set of values like this:

[array]$a = get-qaduser Joe | select-object logonname,lastname,firstname,accountexpires

From here I add each successive value:

$a += get-qaduser Bob | select-object logonname,lastname,firstname,accountexpires
 $a += get-qaduser Fred | select-object logonname,lastname,firstname,accountexpires

Now I can send it to Out-GridView:

$a | Out-GridView -OutputMode multiple

I now have a nice output window where I can copy the values straight to an Excel workbook!

 

Enjoy!