Check Exchange Online storage mailbox policies with PowerShell

There are many health check and compliance items that can be employed in Office 365 to ensure your organization meets with the compliance controls and standards. Microsoft provides PowerShell modules to connect and interact with Office 365 services such as Exchange Online, Office 365 WAAD (Windows Azure Active Directory), SharePoint Online, Microsoft Teams, and so on. One of the items that Office 365 Exchange Online administrators need to do is to get a list of Exchange Online storage mailbox policies.

Warning, send, and receive quota policies

Every mailbox in Office 365 Exchange Online is configured with a quota limit for warning, send, and receive. These storage policies are configured by default in Exchange Online when you create a mailbox. You may want to see how many mailbox storage policies have been configured in Exchange Online by using a PowerShell script. The PowerShell script, provided in this article, can be very handy when you need to evaluate different mailbox storage policies applied in Office 365 Exchange Online.

What does this PowerShell script do?

Before executing the PowerShell script detailed in the later section of this article, please make sure to install Exchange Online modules by using the Install-Module ExchangeOnline and make sure you have Global Administrator access before the script can connect and retrieve the required data. You will also be required to create C:\Temp on the computer from where you run the PowerShell script. 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 Exchange Online.
  • Provides login prompt to connect to Exchange Online.
  • Collects mailbox storage policies from each Office 365 mailbox
  • Checks issue warning quota, prohibit send quota, and prohibit send receive quota storage policies. Actually, the script queries all mailboxes and checks the policies applied.
  • Provides a data file that contains the list of storage policies that have been configured for mailboxes.

PowerShell script

Executing this 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 need to provide your Office 365 connect credentials.

$LocAppDataNow = "C:\Users\Public"
$CurrentLoc="C:\Temp\"
$UniqueTest="EXCH"
 
$TestCSVFile="C:\Temp\TestResult.CSV"
Remove-Item $TestCSVFile -ErrorAction SilentlyContinue
 
Import-Module ExchangeOnline
Connect-ExchangeOnlineShell
 
$TestCSVFile="C:\Temp\TestResult.CSV"
Remove-Item $TestCSVFile -ErrorAction SilentlyContinue
 
$ThisString="Policy Name, Size"
Add-Content "$TestCSVFile" $ThisString
 
$TRCA=$CurrentLoc+"\Data\"+$UniqueTest+"_TRCA.TXT"
Remove-Item $TRCA -ErrorAction SilentlyContinue
 
$TRCB=$CurrentLoc+"\Data\"+$UniqueTest+"_TRCB.TXT"
Remove-Item $TRCB -ErrorAction SilentlyContinue
#$STR="Policy Name, Size"
#Add-Content "$TRCB" $ThisString
 
$Mailboxes = Get-Mailbox -ResultSize Unlimited | Select IssueWarningQuota, ProhibitSendQuota, ProhibitSendReceiveQuota
$AnyGap = "No"
 
ForEach ($Item in $Mailboxes)
{
$ThisCurrentValue = $ITem.IssueWarningQuota
$STR = "Issue Warning Quota, "+$ThisCurrentValue
Add-Content $TRCA $STR
 
$ThisCurrentValue = $ITem.ProhibitSendQuota
$STR = "Prohibit Send Quota, "+$ThisCurrentValue
Add-Content $TRCA $STR
 
$ThisCurrentValue = $ITem.ProhibitSendReceiveQuota
$STR = "Prohibit Send Receive Quota, "+$ThisCurrentValue
Add-Content $TRCA $STR
 
}
 
Get-Content $TRCA | Sort-Object -Unique | Out-File $TRCB
 
ForEach ($ITem in GC $TRCB)
{
$STR = $Item
Add-Content $TestCSVFile $STR
}
 
$TotCount = GC $TRCB
$TotNow = $TotCount.Count
 
IF ($TotNow -gt 3)
{
$SumVal = ""
$TestStatus="High"
$TestText="Different Policies found."
 
}
else
{
$SumVal = ""
$TestStatus="Passed"
$TestText = "PASSED ITEMS"
}

Once the PowerShell script has finished executing you will see a CSV file; C:\Temp\TestResult.CSV, which contains the different mailbox storage policies configured in Office 365 Exchange Online. As you can see in the screenshot below, after executing the PowerShell script it lists the storage mailboxes policies configured in Office 365 Exchange Online.

As you can see in the screenshot, the script retrieved three types of issue warning quota, three types of prohibit send quota, and three types of prohibit send receive quota storage policies. The size of each storage mailbox policy is also given.

Exchange Online storage mailbox policies

You can also see the same result by opening C:\Temp\TestResult.CSV file as shown in the screenshot below:

Exchange Online storage mailbox policies

Important: The above script was retrieved from O365 IT Health & Risk Scanner, which can perform about 102 health and security checks in Office 365 to ensure your Office 365 services are healthy and your organization is meeting the compliance standards.

Featured image: Pixabay

About The Author

1 thought on “Check Exchange Online storage mailbox policies with PowerShell”

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