|
<# |
|
.Synopsis |
|
Backups up and sets the Out of Office message for all shared mailboxes |
|
.DESCRIPTION |
|
Taking a path plus message as input, this cmdlet gets all current mailboxes in specific OU, loops |
|
through and takes a backup of (if any) Out of Office message plus parameters defined for the message. |
|
In the same loop, the message inputted earlier is then defined as a Enabled, External Audience Out of |
|
Office message. |
|
.EXAMPLE |
|
Set-SharedMbxOoo -Path C:\Temp\BackupOfOOO\ -Message "Hello there!" |
|
.NOTES |
|
Version: 1.0 |
|
Author: James Pettigrove |
|
#> |
|
function Set-SharedMbxOoo |
|
{ |
|
[CmdletBinding()] |
|
[Alias()] |
|
[OutputType([int])] |
|
Param |
|
( |
|
# Param1 help description |
|
[Parameter(Mandatory=$true, |
|
ValueFromPipelineByPropertyName=$false, |
|
Position=0)] |
|
[string]$Path = $PSCommandPath, |
|
|
|
# Param2 help description |
|
[Parameter(Mandatory=$true, |
|
ValueFromPipelineByPropertyName=$true, |
|
Position=1)] |
|
[string]$Message |
|
) |
|
|
|
Begin |
|
{ |
|
#Load Exchange Powershell Module |
|
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 "Backing up auto-reply for shared mailbox:" $M.DisplayName |
|
Get-MailboxAutoReplyConfiguration -Identity $M.Alias | Export-Csv -Path "$Path$($M.Alias).csv" -NoTypeInformation |
|
|
|
Write-Host "Setting auto-reply for shared mailbox:" $M.DisplayName |
|
Set-MailboxAutoReplyConfiguration -Identity $M.Alias -ExternalAudience All -AutoReplyState Enabled -ExternalMessage $Message |
|
} |
|
} |
|
} |
|
|
|
Set-SharedMbxOoo |