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

1+

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
	}
1+

Leave a Reply

Close Menu