Scoping External Out of Office Replies

Something I was tasked with a few months ago was scoping down which users could send Out of Office (OOF) replies to external senders. After a little bit of thought, I came up with a pretty quick Powershell script that would accomplish this.

Since the default behavior of a mailbox when created is to allow external OOF replies, this task requires disabling the ones you do not want sending external replies.

In my environment, the users that needed to be scoped were nicely broken out by their OU location in Active Directory. For this reason, I chose to run my query at that level. I created a text file that contained the distinguished name of the OUs containing the users to be disabled that will be called in the script. This way, if things change and another OU of users wants this functionality, all I have to do is enable them via script, then remove their OU from the script that disables them daily.

Here is the script:

I run this every morning at 6:00am to catch all mailboxes that were created in the previous day.

Once the script has been run, the last step is to enable external OOF replies globally (if you don’t already have this in place).

In the Exchange Management Console, navigate to Organization Configuration > Hub Transport > Remote Domains. Choose the default remote domain, which represents any domain you do not control:

Select the option appropriate for your environment. We do not have any legacy clients, so I chose the option above.

At this point, only users that are scoped by your query above will not send out of office replies to external senders, the others will be able to.