Skip to main content

Bulk Backup and Set Out of Office Messages

·430 words·3 mins
system-administration tech exchange exchange-2010 powershell sysadmin technology
James Pettigrove
Author
James Pettigrove
Cloud Engineer with a focus on Microsoft Azure

We live in very interesting times at the moment. No doubt, anyone reading this has been touched by the effects of the spread of COVID-19 across the world.

One requirement that I had in response to the outbreak was to prepare for a full office shutdown. Part of this shutdown would require all of the businesses shared/group mailboxes to display a new Out of Office message to all external parties.

While this task in itself, isn’t too complicated to appear, if the time came to do so, I wanted to ensure that any existing Out of Office message and corresponding configuration was preserved. This way, upon business operations returning to their former state, the previous Out of Office message/configuration can be restored. In doing so, we are taking the burden of the customer to do this (I’m sure they have enough on their plate to catch up on).

So, without further ado, bring forth the Powershell:

Let’s break down a couple of important elements to the code.

First and foremost, my code is targeted at a Exchange 2010 (yes I know, don’t @ me) environment, therefore, I’m loading the Exchange 2010 snap-in:

#Load Exchange Powershell Module
if (! (Get-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction:SilentlyContinue) )
{
    Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction:Stop
}

Feel free to swap out with your version of Exchange that you will be targeting. I do warn you that YMMV. I’ve had random crashes loading or utilising the Exchange modules outside of the Exchange Shell. My recommendation would be to use this code with the Exchange shell versus a regular Powershell shell.

Next up, we need to get all mailboxes of the shared/group variety. Fortunately, the environment I am working on has keep these types to a specific OU, which I am targeting with:

#Get all Shared Mailboxes and loop through each mailbox
$Mbx = Get-Mailbox -OrganizationalUnit "OU=Shared Mailboxes,OU=Users,DC=contoso,DC=co"

Replace the OU with your equivalent. The alternative is to make use of Get-Mailbox’s - RecipientTypeDetails parameter to specify the mailbox type, if you are making use of them in your environment.

Apart from the above two change you may need to make, all you need to do is run the cmdlet and provide both the path for the backup of current OOO message + configuration to be stored plus the new message and your set to go.

So backing up and setting a message in bulk is now straight forward to achieve in your organisation. How do we rollback our OOOs once things settle down and return to normal?

Look out for my next post to learn how.

Stay safe, stay indoors!

Related

Give a computer account Send-As permissions in Exchange Powershell
·189 words·1 min
system-administration tech exchange exchange-2007 exchange-2010 powershell sysadmin technology
Take for instance the File Server Resource Manager that is a feature of the File Server role.
Resolve failed Mailbox Move Requests
·465 words·3 mins
system-administration tech exchange exchange-2010 powershell sysadmin technology
So chances are, after reading my previous post on how to move Mailboxes via Organizational Unit you have migrated a couple hundred mailboxes.
Mailbox Move Request by Organizational Unit
·236 words·2 mins
system-administration tech exchange exchange-2010 powershell sysadmin technology
I’ll admit, I do love Active Directory.