Script to turn a Shared Mailbox into an automated calendar only or a combination of both


The purpose of this PowerShell script is to adjust an existing Shared Mailbox to auto-accept calendar invitations and either keep emails or automatically remove them.

Why would you do that as an admin? Well, there are 2 scenarios for it, and the choice really depends on the department / team in your company and their needs:

1) Its only purpose is a Calendar (e.g. team calendar for vacations)
2) Its purpose is a combination of a Calendar and a Mailbox (e.g. Help Desk mailbox and team calendar for vacations combined rather than two entities separately).

Regardless, the way it works for users – they invite that calendar as a participant when creating vacation bookings. Thus, those bookings will be visible in both a personal calendar and a team calendar.

What this script does:

  • Turns on auto-processing;
  • Allows conflict creation;
  • Either deletes emails or keeps them depending on a scenario from above.
$email = Read-Host "Please provide the email address of a Shared Mailbox"

Set-CalendarProcessing -Identity $email -AllowConflicts $true

Set-Mailbox -Identity $email -Type Room

Set-CalendarProcessing -Identity $email -AutomateProcessing AutoAccept

Set-Mailbox -Identity $email -Type Shared

$answer = Read-Host "Would you like to keep or delete non-calendar items (e.g. emails) ( keep / delete )?"

While ("keep","delete" -notcontains $answer) {
	$answer = Read-Host "Would you like to keep or delete non-calendar items (e.g. emails) ( keep / delete )?"

If ($answer -eq 'keep') {
	Set-CalendarProcessing -Identity $email -DeleteNonCalendarItems $false
	Remove-Variable * -ErrorAction SilentlyContinue

ElseIf ($answer -eq 'delete') {
	Set-CalendarProcessing -Identity $email -DeleteNonCalendarItems $true
	Remove-Variable * -ErrorAction SilentlyContinue

This Post Has 2 Comments

  1. Ian

    Why does this script convert the calendar to a Room calendar then change it back to a shared one? Thanks.

    1. Pavel Bludov

      Hi Ian,
      That is because -AutomateProcessing AutoAccept cannot be set to a Shared Mailbox (you can give it a try). However, it will kept just fine if a conversion happens 1st.
      Thanks for stopping by.


Leave a Reply