If your like me, you don’t like migrating Public Folders and instead encourage people to migrate their public folder content to Shared Mailboxes, M365 Groups or SharePoint sites when moving to Microsoft 365.

Often Public Folders will have calendars that are used by the organization. A common one is an Out of Office or Vacation calendar that needs to be seen by the whole company.

Well if you take a Public Folder and export its calendar to PST and do a pst import into a shared mailbox, you will quickly realize the delimma that the calendar needs to be actually shared out to people because the ‘open from directory’ functionality only opens the primary calendar for the shared mailbox you created – not the calendar that you imported in from a PST.

And since you need to share it out with EVERYONE, manually going and sharing with each person is rediculous – so POWERSHELL IT! But how?

Well first thing you need to do is grab the actual identity value of the calendar. You can do that by connecting to exchange online powershell (Connect-ExchangeOnline) and running the following cmdlet:

Get-MailboxFolderStatistics “sharedmailbox@domain.com” | ft Name, Identity, folderpath, foldertype

Where “Sharedmailbox@domain.com” is the email address of your shared mailbox.

In the output, look for the calendar you imported. If its from a PST file its likely under a IPM_SUBTREE folder.

Once you’ve located it, grab the value of its Identity – so in my screenshot above its “OfficeEmployeesOutOfOffice@domain.com\IPM_SUBTREE\Office Employees – Out of Office”

Now we’re going to use the Set-MailboxFolderPermission (or Add-MailboxFolderPermission if this is the first time adding permissions)
and for the Identity your going to use the value you copied in the previous step, but one small change – add a colon after the email address. So in my example it would be:
Set-MailboxFolderPermission -Identity “OfficeEmployeesOutOfOffice@domain.com:\IPM_SUBTREE\Office Employees – Out of Office”

Now we need to add the -User handle to specify who we want to share it with, and the -AccessRights handle to specify the particular role or permission you want to give hte user to the calendar, and then -SendNotificationToUser $true which will actually email the user an invite to have the calendar shared with them.
So with my example, in total it should look like the following:

Set-MailboxFolderPermission -Identity “OfficeEmployeesOutOfOffice@domain.com:\IPM_SUBTREE\Office Employees – Out of Office” -User testuser@domain.com -AccessRights Editor -SendNotificationToUser $true

When you do that, the end-user will recieve an email like what is tin the screenshot below:

But now you need to share it with everyone right? To do that you can use the following script:

Connect-ExchangeOnline

#Use the following to find the identity of the Calendar: Get-MailboxFolderStatistics “sharedmailbox@domain.com” | ft Name, Identity, folderpath, foldertype
#Paste below into the $Calendar variable and add a “:” after the email address
$Calendar = “OfficeEmployeesOutOfOffice@domain.com:\IPM_SUBTREE\Office Employees – Out of Office”

# Get all users
$Users = Get-User | Where-Object {($_.RecipientType -eq “UserMailbox”) -and ($_.RecipientTypeDetails -ne “SharedMailbox”) -and ($_.Name -notlike “*DiscoverySearchMailbox*”)}

# Share the calendar with all users
foreach ($User in $Users)
{
$DisplayName=$User.DisplayName
write-host “Sharing Calendar with $DisplayName…” -ForegroundColor Yellow
Add-MailboxFolderPermission -Identity $Calendar -User $User.Identity -AccessRights Editor -SendNotificationToUser $true
}

# Disconnect from Exchange Online
Disconnect-ExchangeOnline

———————————————————————-
The output should tell you who its sharing hte calendar with and the white text is the response of the actual permissions being set. If there are existing permissions it will error out with a “An existing permission entry was found” message. If you want to change that existing permission then you can use the Set-MailboxFolderPermission instead of “Add”.