31 C
Dubai
Saturday, November 23, 2024

Automate Enabling Archiving on Hybrid Office 365 Mailboxes

A Simple One Line script on a scheduled task will help you automate enabling archive mailboxes in Office 365. The below example checks for a custom attribute, archive status and enables a set of users in a specific OU. you can change as per your needs. In my case, this custom attribute is mapped to enable licenses dynamically.

# Include Exchange Powershell Module
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn

#Lists All Remote Mailboxes
#Checks Archive Status
#Check License
#Enable Archive Mailboxes

Get-RemoteMailbox | Where-Object {($_.OnPremisesOrganizationalUnit -like "azure365pro.com/01 Users*") -and ($_.Ar
chiveStatus -like "None") -and ($_.CustomAttribute15 -like "O365*")} | Enable-RemoteMailbox -Archive

# Exit Exchange Powershell Module
Remove-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn

But for new users, every time administrators cannot keep checking to make sure Archive mailbox is enabled for my E3 and E5 users. it would be tiring to do it manually every time. So if require you can run it on a task scheduler so that it enables archive mailbox for all my E3 and E5 users.

Supported on Exchange 2013 or above | On-Premise Exchange Hybrid Server

NOTE: Before running the script run the below commands to check which are the mailboxes it will apply to

You can use Task Scheduler

image

Create Basic Task

Choose Daily

image

Set a time

image

Start a Program

image
  • Powershell
  • C:\Scripts\Enable_Archive_Mailbox.ps1
image

Made to stop the task if it exceeds 4 hours

image

Satheshwaran Manoharan
Satheshwaran Manoharanhttps://www.azure365pro.com
Award-winning Technology Leader with a wealth of experience running large teams and diversified industry exposure in cloud computing. From shipping lines to rolling stocks.In-depth expertise in driving cloud adoption strategies and modernizing systems to cloud native. Specialized in Microsoft Cloud, DevOps, and Microsoft 365 Stack and conducted numerous successful projects worldwide. Also, Acting as a Technical Advisor for various start-ups.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

× How can I help you?