Skip to content

Instantly share code, notes, and snippets.

Last active April 4, 2020 05:22
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save DXPetti/2fce15e66034be8c8fc3802077944584 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment