Monitor Work from Home Employees with Employee Desktop Live Viewer.

Read More

How to display Microsoft 365 mailbox information using Exchange Online PowerShell?

Megha Sharma
Megha Sharma Published On - 18 Jun 2020

In this blog, you would learn about using Exchange Online PowerShell to view information related to Microsoft 365 user mailboxes.

Users must have Microsoft 365 administrator or Global Administrator rights to work on Exchange Online PowerShell. Once you are ready with the desired rights, follow the process.

To use the Exchange Online PowerShell, Microsoft 365 administrators must connect their Microsoft 365 accounts to the Windows PowerShell of the system. Here is the way to do that.

Connecting Exchange Online PowerShell
  1. Search for PowerShell on your system, right-click on Windows PowerShell, and select Run as Administrator option.
  2. The Windows PowerShell screen will get opened. First, run this command.
    $UserCredential = Get-Credential

    Running this command will open a dialogue box asking for your Microsoft 365 account login credentials (username and password). Provide them and click OK.

  3. Run the following command.
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
  4. Finally, run this command.
    Import-PSSession $Session -DisableNameChecking
  5. Now, you are connected to the Exchange Online PowerShell.

So, we have provided you the process for connecting to Exchange Online PowerShell above. Now, let us know how this Exchange Online PowerShell helps you get information regarding Microsoft 365 mailboxes.

In Exchange Online PowerShell, there is a Get-Mailbox cmdlet which helps to get Microsoft 365 mailbox information.

Let us know about all its uses.

Mailbox Information
  1. To retrieve mailbox information, try this command.
    Get-Mailbox -ResultSize unlimited

    Output: A summary list of all the mailboxes within the organization.

  2. To receive all the mailboxes within a specific Organization Unit, execute this command.
    Get-Mailbox -OrganizationalUnit <Organizational Unit Name>

    Output: A list of all the mailboxes available within the specified Organization Unit.

  3. To find out the archive mailboxes in a Mailbox Server, use this command.
    Get-Mailbox -Archive -Server <Mailbox Server Name>

    Output: A list of archived mailboxes in the specified Mailbox Server.

There are more uses for the Get-mailbox cmdlet like retrieving properties information from a single or multiple Microsoft 365 mailboxes. Let us go through them.

Mailbox Properties
  1. If you want to get all the properties of a specific user mailbox in your organization, run this command.
    Get-Mailbox -Identity “<user mailbox name>” | Format-List

    Output: All the properties of a specified user mailbox.

  2. To get general information about a specific mailbox, use this command.
    Get-Mailbox -Identity “<user mailbox name>”

    Output: Displays some general mailbox properties such as Name, Alias, Server Name and ProhibitSendQuota

  3. Using the Format List pipeline, users can get prioritized information about the user mailboxes as given below.
    Get-Mailbox -Identity “<user mailbox name>” | Format-List DisplayName, LitigationHoldEnabled, LitigationHoldDate

    Output: Information based on the specified properties in the command – Display Name and Litigation hold properties.

  4. For all mailboxes with specified properties , this is the command.
    Get-Mailbox -ResultSize unlimited | Format-Table DisplayName, LitigationHoldEnabled -Auto

    Output: Shows the specified properties – Display Name, Litigation hold properties for all the mailboxes in the organization.

Now, let us go into more detail and retrieve information related to mailbox folders in the organization using Exchange Online PowerShell commands.

Mailbox Folders Information
  1. To retrieve all the folder in a specific mailbox, use this command.
    Get-MailboxFolder -Identity <mailbox name>

    Output: List of all the root folders within the specified mailbox

  2. For getting information related to a specific folder within the specified mailbox, here is the command.
    Get-MailboxFolder -Identity <mailbox name>:\Inbox

    Output: Inbox folder of the specified user mailbox is retrieved.

  3. To view information related to a specific folder in a user mailbox, this is the command.
    Get-MailboxFolderStatistics -Identity <mailbox name> -FolderScope Calendar

    Output: All the properties of the Calendar folder within the specified mailbox.

It is also possible to know about the mailbox sizes by running some cmdlets in Exchange Online PowerShell.

Mailbox Size Information

To get the size of a specific mailbox, you need to run this command.

Get-Mailbox -Identity <mailbox name> | Get-MailboxStatistics | Format-Table DisplayName, TotalItemSize, ItemCount -Autosize

Output: Information about the specified mailbox.

Also, there comes one more cmdlet which allows exporting information to a CSV file.

Export Mailbox Information

Export your output information after running a cmdlet to a file format like CSV using this command.

Get-Mailbox -ResultSize Unlimited |Select-Object DisplayName,PrimarySmtpAddress,EmailAddresses,EmailAddresses | Export-CSV C:\Temp\”Exchange Online recipients.CSV” –NoTypeInformation -Encoding UTF8

Note: Replace CSV with TXT, XML or HTML file formats in Export-CSV C:\Temp\”Exchange Online recipients.CSV” to save the information to the respective file formats.

Hence, we have learnt about multiple commands in Exchange Online PowerShell which provides users varied information regarding the user mailboxes in the organization.

Summing Up

By connecting PowerShell to Exchange Online and then running certain cmdlets in the Exchange Online PowerShell, you can get a lot of information related to the user mailboxes in the organization. After retrieving information, users can export it to different file formats.