Skip to content

Nandi02/RetentionScript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 

Repository files navigation

RetentionScript

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 ๐Ÿ‘‡


๐Ÿ“Œ Retention Policy Automation Script โ€“ Mailbox to Online Archive

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.

๐Ÿ”‘ Key Features

  • 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.


โš ๏ธ Important Note for Admins

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.

๐Ÿš€ Usage Instructions

Before running the script, make sure you have the required Exchange Online PowerShell module installed and that you are connected to your tenant.

1. Install Exchange Online PowerShell Module

Install-Module ExchangeOnlineManagement -Scope CurrentUser

2. Import the Module (if needed)

Import-Module ExchangeOnlineManagement

3. Connect to Exchange Online

Connect-ExchangeOnline -UserPrincipalName youradmin@domain.com

4. Run the Script

.\RetentionPolicy.ps1

5. Follow the Interactive Prompts

  • 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

About

This repo contains script for exchange mailboxes which will reduce admin tasks

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published