Read time 5 minutes

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

In this technologically advanced era, even a complicated task can be done within a few seconds. So is the case with Office 365. Admins must perform various tasks and that becomes much easier when they start using PowerShell commands. They can be used to manage, audit, view, analyze, and audit the overall functioning of the Exchange Online. Here, we will be discussing how to view the mailbox data using Exchange Online PowerShell.

But before we begin, ensure you have these two pre-requisites:

  • Microsoft 365 administrator or Global Administrator rights to work on Exchange Online PowerShell. Without this, you won’t be able to perform the steps.
  • Microsoft 365 administrators must connect their Microsoft 365 accounts to the Windows PowerShell of the system. If you are confused about this, you can follow the steps given below.

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 open. 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 -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 folders 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 within a few seconds. This saves a lot more time of the users. After retrieving information, users can export it to different file formats.


Q – How do I find the size of my Office 365 mailbox in PowerShell?

A – To view the mailbox size, you must use the Get-MailboxStatistics command with the mailbox identity. This will give you valuable information about your mailbox, including its size, total number of items & more.

Q – What is the PowerShell to check mailbox information?

A – The Get-Mailbox cmdlet is a handy command that allows administrators to view mailbox objects & attributes, as well as populate property pages with essential information. However, you must note that for Exchange Online PowerShell, experts recommend using the Get-EXOMailbox cmdlet instead.

Q – How do I find the number of mailboxes in Exchange Online PowerShell?

A – Head over to the Exchange Admin Center & navigate to recipients > mailboxes. You will find the total mailbox count at the bottom of the page.

Q – How do I find mailbox details in PowerShell?

A – First, make sure you know the identity of the mailbox you want to investigate. Then, use the command Get-Mailbox -Identity “<MailboxIdentity>” | Select-Object * to list out all the properties of that particular mailbox. This command will provide you with a full list of all the mailbox properties, which can be useful information for troubleshooting or management purposes.