Skip to content

Instantly share code, notes, and snippets.

@DXPetti
Last active April 4, 2020 05:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DXPetti/2fce15e66034be8c8fc3802077944584 to your computer and use it in GitHub Desktop.
Save DXPetti/2fce15e66034be8c8fc3802077944584 to your computer and use it in GitHub Desktop.
<#
.Synopsis
Restores Out of Office Message for all shared mailboxes
.DESCRIPTION
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.
.EXAMPLE
Set-SharedMbxOoo -Path C:\Temp\BackupOfOoo\
.NOTES
Version: 1.0
Author: James Pettigrove
#>
function Restore-SharedMbxOoo
{
[CmdletBinding()]
[Alias()]
[OutputType([int])]
Param
(
# Param1 help description
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$false,
Position=0)]
[string]$Path = $PSCommandPath
)
Begin
{
if (! (Get-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction:SilentlyContinue) )
{
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction:Stop
}
}
Process
{
#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
}
}
}
Restore-SharedMbxOoo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment