Formatting output

One of the most common PowerShell questions is how to get information returned from commands in the desired output on the screen. In this recipe, we'll take a look at how you can output data from commands and format that information for viewing on the screen.

How to do it...

To change the default output and view the properties of an object in list format, pipe the command to the Format-List cmdlet:

Get-Mailbox testuser | Format-List

To view specific properties in table format, supply a comma-separated list of property names as parameters, as shown next when using Format-Table:

Get-Mailbox testuser | Format-Table name,alias

How it works...

When you run the Get-Mailbox cmdlet, you only see the Name, Alias, ServerName, and ProhibitSendQuota ...

Get Microsoft Exchange 2010 PowerShell Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.