Set Out of office for multiple users

By | July 12, 2013

If you need to set the out of office for multiple users you can use a powershell script

Set-MailboxAutoReplyConfiguration ALIAS -AutoReplyState scheduled -StartTime "07/12/2013 14:05:00" -EndTime "08/05/2013 08:00:00" -ExternalAudience all -InternalMessage $oof -ExternalMessage $oof

where the variable $oof is a predefined message.

$oof = "I'm not in the office currently"

Here I’ll give a more detailed step by step instructions.

Start by creating an out of office message in outlook for yourself or a test account, we will use a user with the alias test.

Once you’ve created the message together with formatting/fonts etc logon to the exchange server and open the exchange powershell console. Enter the following;

Get-MailboxAutoReplyConfiguration test

This shows the out of office reply setup for alias test. You will see the HTML code for the external message which Outlook has kindly created for us.
Now Place this in variable $x.

$x = Get-MailboxAutoReplyConfiguration test

Now if you enter

$x.InternalMessage

You will only the Internal OOF reply place this into a varible called $oof

$oof = $x.InternalMessage

OK we are now ready to set it for other users using the code at the beginning of the article.

Set-MailboxAutoReplyConfiguration ALIAS -AutoReplyState scheduled -StartTime "07/12/2013 14:05:00" -EndTime "08/05/2013 08:00:00" -ExternalAudience all -InternalMessage $oof -ExternalMessage $oof

The dates are in US format always MM/DD/YYYY.
AutoRepyState can be either disabled, enabled or scheduled (-StartTime and/or -EndTime required).

Now this is OK for setting a few users but what is we want to set the out of office for multiple users.

Start off by creating the signature and getting it into a variable as shown above.

Now create a CSV file with all the aliases you wish to set and call it alias.txt. In a CSV the first line should be the column heading, so in our case alias, the following lines will be the users aliases.

alias
billytest1
billytest2
billytest3

If you would like to get all the alias for a particular group you could use the powershell cmd

Get-DistributionGroupMember -Identity "Group" | Select Alias

Now all we need to do is set the out of office for each user in powershell with the following code

$users = import-csv alias.txt | %{set-mailboxautoreplyconfiguration -identity $_.alias -autoreplystate Scheduled -starttime "10/25/2013 18:00:00" -endtime "11/4/2013 07:00:00" -internalmessage $x.ExternalMessage -externalmessage $x.ExternalMessage}

I hope all this makes sense and helps you out.

2 thoughts on “Set Out of office for multiple users

  1. Anonymous

    Nice post. I learn something totally new and challenging
    on websites I stumbleupon on a daily basis. It’s always helpful to read through content from other authors and practice something
    from other sites.

Comments are closed.