Display Exchange Online mailbox information with Office 365 PowerShell



Summary: Use Office 365 PowerShell to selectively display Microsoft Exchange Online mailbox information.

Get the basics of how to display detailed information on your Microsoft Exchange Online mailboxes using Office 365 PowerShell, in some cases for settings that are not available in the Office 365 Admin center.

Before you get started using Office 365 PowerShell to manage Microsoft Exchange Online, make sure that you have connected to Microsoft Exchange Online PowerShell. For more information, see Connect to Exchange Online PowerShell.

To give you an idea of some of the things you can do with Microsoft Exchange Online and Office 365 PowerShell, let’s take a look at user mailboxes. You can easily get information about a single user mailbox. For example, here’s a command that returns some information about Ken Myer’s mailbox:

Get-Mailbox -Identity "Ken Myer"

This command will return something similar to this:

Name      Alias       ServerName      ProhibitSendQuota
----      -----       ----------      -----------------
kenmyer   kenmyer     bn1pr02mb038    49.5 GB (53,150,220,288 bytes)

You can see things like Ken’s alias and his mail quota. But there’s more information associated with an Microsoft Exchange Online mailbox than just the four properties returned by the Get-Mailbox cmdlet.

Here’s an example command that displays all the information for a specific mailbox:

Get-Mailbox -Identity "Ken Myer" | Select-Object *

The syntax | Select-Object * instructs Office 365 PowerShell to return all the information that can be returned by the Get-Mailbox cmdlet. There are about 200 different properties and property values. You can also use the Select-Object cmdlet to specify a set of property values to be displayed. For example, you can also view litigation hold-related properties for Ken Myer with this command:

Get-Mailbox -Identity "Ken Myer" | Select-Object DisplayName, LitigationHoldEnabled, LitigationHoldDate, LitigationHoldOwner, LitigationHoldDuration

You can also use wildcard characters when working with the Select-Object cmdlet. For example, all the litigation hold properties start with the letters lit. You can retrieve this same information by using this command:

Get-Mailbox -Identity "Ken Myer" | Select-Object DisplayName, Lit*

This command tells Get-Mailbox to retrieve the value of Ken’s DisplayName property along with the values of any properties that have names that begin with the letters lit. Here is an example of what we get back:

DisplayName            : Ken Myer
LitigationHoldEnabled  : False
LitigationHoldDate     :
LitigationHoldOwner    :
LitigationHoldDuration : Unlimited

You can obtain information about multiple mailboxes by leaving out the Identity parameter. Here is an example of obtaining the Display Name and LitigationHoldEnabled properties for all mailboxes:

Get-Mailbox | Select-Object DisplayName, LitigationHoldEnabled

In many cases, you will want to look at a subset of your mailboxes. For example, suppose you are asked to come up with a list of all the mailboxes that have been assigned a litigation hold. You can use the Where-Object cmdlet in conjunction with the Get-Mailbox cmdlet. The Where-Object cmdlet needs a filter phrase to tell PowerShell what set of mailboxes you are interested in.

In their simplest form, filter phrases consist of:

  • A property name

  • A comparison operator

    Here are the most commonly used comparison operators:

    • -eq for equals (an exact match)

    • -ne for not equals (not an exact match)

    • -gt for greater than

    • -lt for less than

    For a complete list, see Where-Object.

  • A value that the comparison operator is comparing to the value of the named property

    Typical values of properties are strings, numerical values, boolean values ($True or $False), or no value ($Null).

Returning to our example of all the mailboxes that have been assigned a litigation hold, the filter phrase is LitigationHoldEnabled –eq $True:

  • LitigationHoldEnabled is the property name

  • -eq is the comparison operator

  • $True is the value of the LitigationHoldEnabled property for our desired subset of mailboxes

Once you have the filter phrase, you can construct the Where-Object portion of the command using this syntax:

Get-Mailbox | Where-Object {$_.<filter phrase>}

Here is the command for our example:

Get-Mailbox | Where-Object {$_.LitigationHoldEnabled -eq $True}

For another example, suppose you’d like to make sure that all of your users have the junk email rule enabled. Here’s a quick command to determine if any of your users don’t have that rule enabled:

Get-Mailbox | Get-MailboxJunkEmailConfiguration | Where-Object {$_.Enabled -eq $False}

Because there is no way to do this using the Office 365 Admin center, you must use Office 365 PowerShell. This is just one example. If you want to display a set of mailboxes based on a setting and cannot filter on that setting in the Office 365 Admin center, do the following:

  1. Determine the mailbox property corresponding to the setting.

    Use the Get-Mailbox –Identity "<name>" | Select-Object * command to list all the properties of a mailbox.

  2. Construct your Office 365 PowerShell command from the following:

    • Get-Mailbox | Where-Object {$_.

    • your filter phrase containing the property, the comparison operator, and the value

    • }