Out-GridView Awesomeness

This post is more for me than anybody else but some may find it useful. I feel a bit late to this particular party, but I have recently encountered the awesomeness that is Out-Gridview, and have started using it to help me easily define variables. Here is an example. I want to display a list of all Mail Users and then select the objects which I would like to save to a variable. To do this I can run the following command:

$mailuser = Get-MailUser | Select Name,UserPrincipalName,RecipientType |  Out-GridView -Title "Select Mail User" -PassThru

This gives me a selection box, containing the columns I specified, which I can then use to select the mail users I need for my variable. I can also search and define additional criteria to filter by. As I want to select multiple mail users, I can just Ctrl select as many users as I’d like and then click OK. Obviously IRL there would not be a gigantic black box covering your view, I am just protecting the innocent here!


If I now use $mailuser to show the results of my variable, I can see that the users I selected are there and I can manipulate them as I see fit. How I’ve lived my life before Out-Gridview I don’t know, but now I’ve found it I’m sure to cherish it for all time!