As you may or may not know, Outlook has a facility to import known public holidays. However, currently while these holidays will be imported into the Outlook calendar, the status of these holidays is set to Free. An often received request is for advice on how to change this status to Busy, or OOF. If you search the internet, there are quite a few examples of scripts that can do this within Outlook - but how to do this on an orgnaisation level?
PowerShell and EWS can be used to process mailboxes directly on Exchange. The holidays that are imported are all identified by being category "Holiday", so all we need to do is go through the calendar folder of a mailbox and change the status of all appointments categorized as Holiday. I've attached a PowerShell script that does exactly this. It can be used to change the status as desired, and the parameters are described below.
When developing this script I came across a perplexing error when using the EWS Managed API 1.2. Autodiscover worked fine, but when I sent any requests using the managed API, I received an error: "The underlying connection was closed". After some investigation, it seems that the managed API 1.2 was not sending authentication information for any of the requests (even though it was specified in the code). I went back to the managed API 1.1, and this problem was resolved. The issue only appears when using the managed API from PowerShell, and I am trying to find out more information, as it seems rather odd. So, if you have a similar issue, try the 1.1 API.
Set-HolidayStatus -Mailbox <string> -Status <string> [-Username <string> -Password <string> [-Domain <string>]] [-Impersonate <bool>] [-EwsUrl <string>] [-EWSManagedApiPath <string>] [-IgnoreSSLCertificate <bool>]
Required: -Mailbox : Mailbox SMTP email address -Status : Free, Tentative, Busy, or OOF
Optional: -Username : Username for the account being used to connect to EWS (if not specified, current user is assumed) -Password : Password for the specified user (required if username specified) -Domain : If specified, used for authentication (not required even if username specified) -Impersonate : Set to $true to use impersonation. -EwsUrl : Forces a particular EWS URl (otherwise autodiscover is used, which is recommended) -EWSManagedApiDLLFilePath : Full and path to the DLL for EWS Managed API (if not specified, both 1.2 and 1.1 will be searched) -IgnoreSSLCertificate : If $true, then any SSL errors will be ignored