Bulk Enable Exchange Online Archiving – PowerShell Script

Bulk Enable Exchange Online Archiving – PowerShell Script

This script enables the Online Archiving Mailbox for users in Exchange Online. The script will generate the log and error outputs by checking if the users exists in Exchange Online based on the information provided in the csv file.

The script needs to be run from the On-prem Exchange environment.

Example of script block, this demonstrates the actions taken within the script to check the csv file row by row and output if sucessful or not.

Foreach ($row in $csv)
{
if (get-remotemailbox -identity $row.mailboxemail)
{
get-remotemailbox -identity $row.mailboxemail | enable-remotemailbox -archive
Add-Content -Path $logfilepath -Value ('{0} SUCCESS: Mailbox {1} enabled for Archive' -f (Get-Date), $row.mailboxemail)
}
else {
$outputfiles |%{ Add-Content -Path $_ -Value ('{0} ERROR: Mailbox {1} not enabled for Archive {2}' -f (Get-Date), $row.mailboxemail, $_.exception.message)}
}
}

Example of csv file used; please note the heading mailboxemail is very important as the script checks for this heading.

To view if an Online archive has been activated in the Mailbox, run the following cmdlets.

It is very easy to enable Online Archiving and verify afterwards if it has been enabled.

Download this script

Enable-RemoteMailbox -Archive (39 downloads)

Regards

Author – Blogabout.Cloud