I often switch workplaces, and it’s easier to set my out of office (OOO) when I’m not on site, both for me as for my colleagues. However, having to wade through the Outlook settings just to reach the OOO settings is tedious. And because anyone in IT worth their salt automates as much as they can, why not this?
Assumptions/limitations:
- You’re using Office 365.
- The script works with full days, in other words: you cannot start or end your OOO halfway through the day.
You’ll need two PowerShell modules: BurntToast
and ExchangeOnlineManagement
. The latter is necessary, the former only if you want the notification at the end of the script (you can remove the call to New-BurntToastNotification
if you don’t).
Installation is straightforward:
Install-Module -Name ExchangeOnlineManagement
Install-Module -Name BurntToast
Next, you need the Get-GuiDate.ps1
script (see here), which shows a calendar popup to select the from/until date. The main script assumes that the Get-GuiDate.ps1
script is located in the same folder.
At the top of the script, you might have noticed this line:
$DateFormatCulture = [CultureInfo]'en-GB'
While not strictly necessary, it prevents the ToString()
output from changing depending on the environment. This only matters if you plan on using the script on different computers, or if you want to output the date in a different language (in my case, I want it to say Tuesday instead of Dinsdag).
Here’s what the end result looks like in Outlook:
All that’s left is to make a shortcut on our desktop/taskbar/start menu to quickly call the script. Here’s the commandline you’ll need to use:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file Set-OOO.ps1
Tip:
- Don’t forget to set the work directory (Starts in).
- If you set the window style to Minimised, you’ll only see the calendar and windows notification (other than the authentication popup).
- Have a look at the documentation of
Set-MailboxAutoReplyConfiguration
to see how you can configure your OOO to your liking.
Code
Reference
- Set-MailboxAutoReplyConfiguration (ExchangePowerShell) | Microsoft Docs
- About the Exchange Online PowerShell V2 module | Microsoft Docs
- Get-GuiDate: A PowerShell Calendar Tool – SAPIEN Blog
- GitHub - Windos/BurntToast: Module for creating and displaying Toast Notifications on Microsoft Windows 10.
- Formatting Date and Time (with Culture) - Power Tips - Power Tips - IDERA Community