Restore Out of Office Backup with Powershell

In my previous post, I discussed the need to set a special external facing Out of Office message for all shared mailboxes in the organisation. Prior to doing so, I ensured we backed up the current message, along with it’s configuration.

Hopefully you followed along and did the same as now is the time to restore our old message and configuration.

Once again, we will look to the power of Powershell (heh) to help us out:

Restores Out of Office Message for all shared mailboxes
Taking a path as input to location of backups created with the corrosponding cmdlet Set-SharedMbxOoo,
this cmdlet gets all current mailboxes in specific OU, loops through and restores (if any) Out of
Office message plus parameters defined for the message.
Set-SharedMbxOoo -Path C:\Temp\BackupOfOoo\
Version: 1.0
Author: James Pettigrove
function Restore-SharedMbxOoo
# Param1 help description
[string]$Path = $PSCommandPath
if (! (Get-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 ErrorAction:SilentlyContinue) )
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 ErrorAction:Stop
#Get all Shared Mailboxes and loop through each mailbox
$Mbx = Get-Mailbox OrganizationalUnit "OU=Shared Mailboxes,OU=Users,DC=contoso,DC=co"
ForEach ($M in $Mbx)
Write-Host "Restoring auto-reply for shared mailbox:" $M.DisplayName
$OldOOO = Import-Csv Path "$Path$($M.Alias).csv"
Set-MailboxAutoReplyConfiguration Identity $M.Alias `
AutoReplyState $OldOOO.AutoReplyState `
EndTime $OldOOO.EndTime `
ExternalAudience $OldOOO.ExternalAudience `
ExternalMessage $OldOOO.ExternalMessage `
InternalMessage $OldOOO.InternalMessage `
StartTime $OldOOO.StartTime

The restore cmdlet takes much of it’s DNA from the backup cmdlet. Therefore the same rules apply.

Change the Exchange module to one that is applicable in your environment:

        #Load Exchange Powershell Module
        if (! (Get-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction:SilentlyContinue) )
            Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction:Stop

And point the cmdlet to where your shared mailboxes are:

        #Get all Shared Mailboxes and loop through each mailbox
        $Mbx = Get-Mailbox -OrganizationalUnit "OU=Shared Mailboxes,OU=Users,DC=contoso,DC=co"

Once the above two elements are matched to your environment, run the cmdlet. The only parameter you will need to provide is the path to where the backups are located.


You’ve now saved your customers a enormous amount of time not worrying about settings things back to how they were. Productivity is on the rise!

James Written by:

One Comment

Helpful? Have a question on the above?