33 C
Dubai
Tuesday, September 21, 2021
spot_img

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 Manoharanhttps://www.azure365pro.com
Satheshwaran Manoharan is an Microsoft Office Server and Services MVP , Publisher of Azure365pro.com. Specialized in Office365 / Microsoft Exchange / Virtualization , Sathesh is an Messaging Expert supporting/Designing/Deploying many medium size businesses to large enterprises when it comes to Corporate messaging and Virtualization Infrastructure

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here