-->

Saturday, February 8, 2020

Exchange Set OOF/AutoReply Template For Specific Mailboxes

I recently got a request from one of our location managers to implement a standard Out Of Office (OOF or Automatic Reply in Exchange lingo) because it seems users weren't using appropriate verbiage when creating their own.
Not a bad idea really...the issue I have is: we run a Resource Forest, and we use Custom AD Attributes for location codes that get sync'd from the Accounts Forest.
In order to set the OOF template by attribute, I had to do some fancy footwork in PowerShell to ensure only those specific users got the template.

In my example, we'll be using two AD attributes (CustomAttribute15 and ExtensionCsutomAttribute1) because that's what we set in my environment. You might be thinking "my organization is NORMAL, how can I set them by using something like the Office attribute?" That's easily doable, so I'll go over that later.

First, we'll want to check who has AutoReply currently enabled, because we don't want to overwrite those, as it will be sending a non-descriptive reply with no user-specific info and might confuse recipients.

To export a list of who has OOF set, run the following cmdlet in the Exchange Management Shell:

Get-Mailbox -Resultsize Unlimited | where {($_.CustomAttribute15 -eq 'USNY') -or ($_.ExtensionCustomAttribute1 -eq 'USNY')} | Get-MailboxAutoReplyConfiguration | where {$_.AutoReplyState -eq "disabled"}| Select Identity,StartTime,EndTime,AutoReplyState | Export-Csv NY_oof.csv

In the above cmdlet, we're checking for the auto reply in a "disabled" state for users who are located in New York (the USNY attribute). The reason we used AutoReplyState -eq "disabled" and not enabled is because the state could have also been "scheduled" so even though disabled will prolly give a lot of results, it's more fail-safe.

Next, we'll build our template into a variable using HTML formatting by running:

$reply = "<html><head></head><body><p>Thank you for your email.  I am out of the office from [DAY], [MONTH/DATE] through [DAY], [MONTH/DATE] and with limited access to email OR do not have access to email.  I will respond to your email as soon as possible.</br></br>For urgent topics, please text me on my cell at [PHONE], or if you need immediate assistance, please contact, [NAME] at [EMAIL] or [PHONE].</p></body></html>"

**Note** Feel free to change the text between the first and last "< p >" tags to fit your organization.

Setting Template By Attributes:

Now, we'll implement the template on the mailboxes that we checked earlier, with:

Get-Mailbox -Resultsize Unlimited | where {($_.CustomAttribute15 -eq 'USNY') -or ($_.ExtensionCustomAttribute1 -eq 'USNY')} | Get-MailboxAutoReplyConfiguration | where {$_.AutoReplyState -eq "disabled"} | Set-MailboxAutoReplyConfiguration –InternalMessage $reply -ExternalMessage $reply

The above cmdlet will set the HTML reply for both internal and external AutoReplies, for the users in NY, who don't have OOF enabled. It will not enable OOF, it will only set the text in the reply for when users go to enable it themselves.

Setting Template By Office:

Earlier I said we can do it using more "standard" attributes, here's how: To set the reply template according to the "Office" attribute, we'll do the following:

Get-Mailbox -Resultsize Unlimited -Filter "Office -like 'New York'" | Get-MailboxAutoReplyConfiguration | where {$_.AutoReplyState -eq "disabled"} | Set-MailboxAutoReplyConfiguration –InternalMessage $reply -ExternalMessage $reply

Setting Template For All:

What if we wanted to set it on all mailboxes? Even easier, and frankly what I would do if management would let me. To do that, run:

Get-Mailbox -Resultsize Unlimited | where {$_.AutoReplyState -eq "disabled"} | Set-MailboxAutoReplyConfiguration –InternalMessage $reply -ExternalMessage $reply

Now, we can spot check and see that the template has been set on a couple users from our original CSV export.

In the Shell, run the following:

Get-Mailbox "stacey branham" | Get-MailboxAutoReplyConfiguration

Or, you can check in the EAC, by clicking your name in the upper right corner, select "another user", find the user in the GAL, and select "Set up an automatic reply message" in the right pane.

The results will be shown in the internal and external message boxes.

Now your users will have a standard AutoReply!

No comments:

Post a Comment