Perfect โ Thanks for pointing that out. Since the main admin action is to review and update the retention policies inside the script so they match whatโs available in their own environment, Iโll update the README to highlight this clearly.
Hereโs the improved version ๐
This PowerShell script is built to streamline the process of applying retention policies to user mailboxes in Exchange Online. Instead of manually searching, applying policies, and running folder management tasks, this script automates the entire workflow, saving administrators valuable time.
- Interactive User Selection โ Prompts the admin to enter a userโs name and retrieves detailed mailbox information.
- Policy Overview โ Displays all retention policies available in the environment so the admin can easily choose or update the correct one.
- Automated Retention Assignment โ Applies the selected retention policy to the userโs mailbox without manual intervention.
- Start-ManagedFolderAssistant โ Automatically runs the folder management assistant to immediately enforce the retention settings.
- Mailbox Storage Insights โ Provides a detailed breakdown of the userโs storage usage in gigabytes (GB) and megabytes (MB).
- Automated User Notification โ Sends an email notification to the user informing them of the retention policy change, with Q-Auth authentication for secure admin actions.
- Admin Time Saver โ Reduces manual steps required to configure retention, run compliance assistants, and check mailbox usage.
This script is especially helpful for Microsoft 365 / Exchange Online administrators who want to automate policy application and enforcement while maintaining transparency with users.
The major change required before using this script is to update the retention policies inside the script so they match the policies configured in your Exchange Online environment.
- Review your available retention policies in the Microsoft 365 Compliance Center or via PowerShell (
Get-RetentionCompliancePolicy
). - Edit the script to include these policy names/IDs.
- Once updated, the script will display and apply them correctly to users.
Before running the script, make sure you have the required Exchange Online PowerShell module installed and that you are connected to your tenant.
Install-Module ExchangeOnlineManagement -Scope CurrentUser
Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline -UserPrincipalName youradmin@domain.com
.\RetentionPolicy.ps1
-
Enter the target username when prompted.
-
Review the mailbox details displayed.
-
Select or update the retention policy shown from your environment (
โ ๏ธ must be updated in the script before use). -
The script will automatically:
- Apply the policy
- Run
Start-ManagedFolderAssistant
- Show storage usage in GB/MB
- Send an email notification to the user regarding the changes