Out Of Office [Time, Date Based – Part 1]

My first contribution is about the automation of OOF (Out Of Office). Because it robs me 4 minutes every day.
In doing so, it is decisive which principles applies to the OOF settings. This is a personal requirement and can be defined individually.

Generally, I see several possibilities:

  1. if Outlook is closed, I am OOF
  2. if a certain time or / and day, I am OOF
  3.  if there is a certain event in my calendar then I am also OOF
  4. Of course, all settings can also apply to you together or individually.


First of all I will show you the possibility to set up OOF based on time and day. No special application is required, we will do all in PS.


To visualize the whole thing briefly, here is a BPMN.

To Connect to Exchange Online

# Create new Session and store it on the var $Session, use the Get-Credentials for username and password
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential (Get-Credentials) -Authentication Basic -AllowRedirection

#Import PS Session
Import-PSSession  $Session

After the snipped above, you are connected to Exchange Online. After you can get the current configuration with the following snippet

Get-MailboxAutoReplyConfiguration -Identity $mailaddress | Select-Object AutoReplyState,*time

Ok, now you are connect and has get the current configuration, you can now set the new OOF with Set-MailboxAutoReplyConfiguration.

This is the manual way and gives us the basics for the automated script.


Microsoft Links:


Leave a Reply

Your email address will not be published. Required fields are marked *