How to add holidays to the Exchange calendar with PowerShell

There is a feature in Microsoft Outlook that allows users to add various regional public holidays to their calendar. In this post, I’ll show you how you add holidays to the Exchange calendar with a little PowerShell scripting.

If you didn’t know this Outlook feature, you’ll find it in File > Options > Calendar > Add Holidays. Although this is a nice feature, most users probably don’t know it exists, let alone use it. It is possible that your organization might want these holidays to be automatically added to each user’s calendar without any intervention from users themselves.

We’ll start by creating a template Exchange mailbox. In my example, I just used my “helpdesk” mailbox, as the calendar is empty in it.

Once you have a mailbox to use as your template, open it in Microsoft Outlook. We will then import the holidays using the “Add Holidays” feature of Outlook (File > Options > Calendar > Add Holidays). Once the holidays have been added to the calendar, review and amend as required. (I had to remove a few that didn’t apply to us.) The search feature works well here, as the holidays go quite far into the future!

We can check with the Exchange PowerShell Console to see if the number of items seems correct, using the following command:

So, in my case, we’re going to be adding 112 calendar entries to everyone’s calendars, as shown in the following screenshot:

Get-MailboxFolderStatistics

Get-MailboxFolderStatistics

If you’re happy with this, the next stage is to export the calendar items to a .PST file. By default, Microsoft Exchange does not grant anyone export/import rights to mailboxes—not even administrators! So we’ll have to grant ourselves permission to do this first.

We can grant the right to an individual user, such as “geoff,” with the following cmdlet:

However, I always prefer to grant the right to an Active Directory security group. For example:

Now that we’ve got rights to export the calendar to the .PST file, we can do so as follows:

This command doesn’t perform the export but creates an export request with Exchange. We can observe the export list and progress with the following command:

After a moment or two, you’ll see that the request has completed, and you should see a .PST file in the location specified in the New-MailboxExportRequest command.

At this stage, we’re ready to import the calendar into other Exchange mailboxes. Before we go crazy on all of our users, it’s probably advisable to test on just one first. Let’s import the calendar entries into Bob’s calendar. Do so as follows:

If you decide to build this into the scripts/process you run for setting up new users, this will be the command you need for the new accounts. As before, this isn’t imported instantly; rather, it is added to an import queue. You can watch the status with the following command:

Once we’re happy with the result, we can proceed to import to all of our users with a PowerShell command that loops though all of our mailboxes and creates an import request for each:

This part will take quite a while to complete, but you can watch the mailbox import requests with the command we used earlier.

Once all import requests have completed, all users will have your predefined holidays in their calendars.

It’s also worth noting that the steps above can apply to anything that you might find in an Exchange mailbox, and the calendar entries don’t have to only be holidays. You can get quite creative with it!

Join the 4sysops PowerShell group!

Your question was not answered? Ask in the forum!

0
8 Comments
  1. CypherBit 6 years ago

    Could this or is there a better method be used to frequently copy items from users calendar to a central calendar (think vacation calendar). To automate this, so the users don't have to enter (drag/drop) items in two calendars.

    0

  2. Josh 6 years ago

    I have a question, I have many different Windows 7 users connecting thru a VPN using Juniper Network Connect, is there a way to apply policy changes to all the users upon connecting? It's acceptable if the connecting user must grant permission via security prompt.

    0

  3. Simon Powell 5 years ago

    Hi Geoff

    Long time no speak since our days at Bentleys/Italik. Just looking at this for our organisation and just wondered if if you had problems with delegate permissions being reset on Calendars after doing an global import? Hope all is well mate. Cheers Simon

    0

  4. Mitch Miller 4 years ago

    We used this method and had room calendar permissions set to default, shared calendars lost reviewer permissions, and delegates were all removed from individual calendars. This is  a small disaster.

    1+

    • heckmanz 3 years ago

      The same happened to me, stupid of me to test and use me or another IT person as a test.. should have tested outside my bubble.  All permissions stripped the past apts on the helpdesk calendar all showed up with invites that had to be dismissed for all 800+ users.  All permissions were removed for shared users and had to be scripted or granted access all over again, augh.  Today I found that the permissions for the Calendar that I had on the calendar overwrote everyone else's.  So by default we only saw free or busy on everyone's calendar unless granted more access, well now everyone can see everyone's information across the board.  Nothing like making a leap of faith and falling face first.  Lesson learned here.  Test environment goes up soon.

      0

  5. Gus 2 years ago

    This is great! Exactly what I was looking for.

    Can you import to members of a distribution group? As oppose to every exchange mailbox.

    Thanks!

    0

  6. Dawit 2 years ago

    New-MailboxExportRequest : The term 'New-MailboxExportRequest' is not recognized as the name of a cmdlet, function,
    script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
    correct and try again.

    Get-MailboxExportRequest : The term 'Get-MailboxExportRequest' is not recognized as the name of a cmdlet, function,
    script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
    correct and try again.

    1+

  7. finesherb 2 years ago

    This cmdlet is available only in on-premises Exchange

    0

Leave a reply

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

*

© 4sysops 2006 - 2020

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account