Exchange Online mailboxes capabilities: Check them with PowerShell

Microsoft provides Office 365 PowerShell modules to work with services such as Exchange Online, Office 365 WAAD, SharePoint Online, Microsoft Teams and so on. One of the tasks that every admin performs is to ensure the capabilities assigned to mailboxes are matching with the number admins have documented. For example, you have BPOS_S_Standard and BPOS_S_Enterprise capabilities configured in Office 365 and you want BPOS_S_Standard capability to be applied to a few users and BPOS_S_Enterprise capability to be applied to sales and finance teams. You may want to see how many users in Office 365 are using the different capabilities you have configured. We provide a PowerShell script that can help you collect the required information about the assigned Exchange Online mailboxes capabilities in a CSV file for your easy reading.

Before executing the PowerShell Script

Before executing the PowerShell script in the later section of this article, please make sure you meet the following requirements:

  1. Install Exchange Online modules by using the Install-Module ExchangeOnline method.
  2. Make sure you have global administrator access before the script can connect and retrieve the required data.
  3. You will also be required to create C:\Temp on the computer from where you run the PowerShell script.

What does the PowerShell script do?

The PowerShell script provided in a later section of this article performs the following operations:

  • Imports the PowerShell modules required to connect to Office 365 MSOnline.
  • Provides login prompt to connect to Office 365.
  • Collects mailboxes from Office 365.
  • Check capabilities assigned to each mailbox and then report the output to a CSV file.

PowerShell script

Executing the PowerShell script will generate a report in CSV format. The report file can be found at C:\Temp\TestResult.CSV and the data file can be found under C:\Temp\Data folder. You will need to provide your Office 365 connect credentials.

$LocAppDataNow = "C:\Users\Public"

Remove-Item $TestCSVFile -ErrorAction SilentlyContinue
Remove-item $TestCSVFile
Import-Module ExchangeOnline

$ThisString="Capabilities, Assigned To Mailboxes, Data File"
Add-Content "$TestCSVFile" $ThisString

Remove-Item $DataFileLocation -ErrorAction SilentlyContinue
$STR = "Capabilities, Mailbox"
Add-Content $DataFileLocation $STR

$AllMailBox = Get-Mailbox -ResultSize Unlimited | Select-Object DisplayName, PersistedCapabilities

$TRCFile = $CurrentLoc+"\Data\"+$UniqueTest+"_TRC.CSV"
Remove-Item $TRCFile -ErrorAction SilentlyContinue
$STR = "Policy,Tot"
Add-Content $TRCFile $STR

$AnyGap = "No"

ForEach ($Item in $AllMailBox)
$PRNow = $Item.PersistedCapabilities
$arr = @($PRNow)
$Policy = [string]::Concat($arr)

IF ($Policy -eq "" -or $Policy -eq $Null)

$FoundOrNot = "No"
$TRCCSV = Import-CSV $TRCFile
ForEach ($PolicyNow in $TRCCSV)
IF ($PolicyNow.Policy -eq $Policy)
$FoundOrNot = "Yes"

IF ($FoundOrNot -eq "No")
$TotCountNow = 0
ForEach ($AllCounts in $AllMailBox)

$SetNow = $AllCounts.PersistedCapabilities
$arr = @($SetNow)
$NewSetNow = [string]::Concat($arr)

IF ($NewSetNow -eq $Policy)
$DispName = $AllCounts.DisplayName
$STR = $Policy+","+$DispName
Add-Content $DataFileLocation $STR

$STR = $Policy+","+$TotCountNow.ToString()
Add-Content $TRCFile $STR
$STR = $Policy+","+$TotCountNow.ToString()+","+$DataFileLocation
Add-Content $TestCSVFile $STR


$TotPolNow = Import-CSV $TestCSVFile
$TotPolCount = $TotPolNow.Count

#Remove-Item $TRCFile -ErrorAction SilentlyContinue

IF ($TotPolCount -gt 1)
$SumVal = ""
$TestText = ""
$SumVal = ""
$TestText = ""


Once the above PowerShell script has finished executing you will see a CSV file, C:\Temp\TestResult.CSV, which contains the capabilities and number of mailboxes using the capability. The file under C:\Temp\Data contains the mailboxes that are using the capabilities. The data file name is C:\Temp\Data\EXCH_Data.CSV

As you can see in the screenshot below, which is taken from O365 IT Health & Risk Scanner, after executing the PowerShell script it lists the name of the capability and number of mailboxes using the same capability.

exchange online mailboxies

The PowerShell script to check Exchange Online mailboxes capabilities was retrieved from O365 IT Health & Risk Scanner, which can perform about 97 checks in Office 365 to ensure your Office 365 services are healthy and your organization is meeting compliance standards.

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top