Powershell: Manage OOTO

To get the existing Out of Office/Auto Reply settings for a specific user:
Get-MailboxAutoReplyConfiguration "user"

Which should return something similar to this:
RunspaceId       : 557b047e-4a9e-4852-86b9-dff1d2072082
AutoReplyState   : Scheduled
EndTime          : 7/2/2012 8:00:00 AM
ExternalAudience : All
ExternalMessage  : I am out of the office and will return on Monday, July 2.
InternalMessage  : I am out of the office and will return on Monday, July 2. I will have LIMITED access to email. If you need assistance, please contact "different user" (ext. ####).
StartTime        : 6/27/2012 5:00:00 PM
MailboxOwnerId   : domain.local/Users and Computers/IT/user
Identity         : domain.local/Users and Computers/IT/user
IsValid          : True

Disable Out of Office/Auto Reply and clear the Internal/External message:
Set-MailboxAutoReplyConfiguration -identity "user" -AutoReplyState disabled -InternalMessage "" -ExternalMessage ""

Set auto reply settings for a mailbox:
Set-MailboxAutoReplyConfiguration -identity "user" -AutoReplyState enabled -InternalMessage "message" -ExternalMessage "message"

Set a scheduled auto reply settings for a mailbox:
Set-MailboxAutoReplyConfiguration -identity "user" `
-AutoReplyState Scheduled -StartTime "6/27/2012 17:00:00" -EndTime "7/2/2012 8:00:00" -InternalMessage  "I am out of the office and will return on Monday, July 2.  I will have LIMITED access to email.  If you need assistance, please contact "different user" (ext. ####)." `
-ExternalMessage  "I am out of the office and will return on Monday, July 2." 

To get a list of all currently enabled Out of Office/Auto Reply (for active accounts which have logged in within the past 90 days):
$3Months = Get-Date
$3Months = $3Months.AddMonths(-3)
Get-exchangeserver | ?{$_.ServerRole -eq "Mailbox"} | `
Get-mailbox -results Unlimited | ?{$_.OrganizationalUnit -notlike "*disabled*"} | `
Get-MailboxStatistics | ?{$_.LastLogonTime -lt $3Months} | `
Get-MailboxAutoReplyConfiguration | ?{$_.AutoReplyState -eq "Enabled"} | `
select Identity,EndTime | ft -auto

No comments:

Post a Comment