Creating Microsoft Exchange room resources via PowerShell

This article contains a PowerShell script than can be used to create Microsoft Exchange room resources in a Microsoft Office 365 environment.

It is particularly aimed at creating room resources for use in a One-Touch Join environment as it associates the room resource with a service account and sets our recommended calendar processing options.

You need to run PowerShell as administrator. This script:

  1. Installs the ExchangeOnlineManagement and AzureAD modules if they do not already exist.
  2. Connects the user to Microsoft Entra ID and Exchange.
  3. Prompts the user to enter the properties of the room resource to be created and the service account to manage it.
  4. Creates the room resource (mailbox).
  5. Assigns the nominated service account permission to manage the room resource.
  6. Configures our recommended calendar processing settings for the room resource.
Copy to clipboard
#Set Execution Policy
Set-ExecutionPolicy RemoteSigned
#If not installed, install Exchange Online Module 
Install-Module ExchangeOnlineManagement
#If not installed, install Azure AD Module 
Install-Module -Name AzureAD
#Connect to Exchange Online and AzureAD, works also with a MFA enabled account
Connect-AzureAD
Connect-ExchangeOnline
#gather input for Pexip Room name and Password
$prn = Read-Host -Prompt ‘Enter the room name’
$pwd = Read-Host -Prompt ‘Enter the password’ -AsSecureString
$displayname = Read-Host -Prompt ‘Enter the display name’
$domain = Read-Host -Prompt ‘Enter the domain name here’
$ServiceAccount = Read-Host -Prompt ‘Enter the service account name’
#Create the Resource Account
New-Mailbox -MicrosoftOnlineServicesID "$prn@$domain" -Alias $prn -Name "$prn" -DisplayName "$displayname" -Room -EnableRoomMailboxAccount $true -RoomMailboxPassword (ConvertTo-SecureString -String $pwd -AsPlainText -Force)
#Set the Access Permissions for the Service Account
Add-MailboxPermission -Identity "$prn@$domain" -User "$ServiceAccount" -AccessRights FullAccess
#Configure the Calendar Processing for the Resource Account
Set-CalendarProcessing -Identity "$prn@$domain" -AutomateProcessing AutoAccept -DeleteComments $False -DeleteSubject $False -AddOrganizerToSubject $False -RemovePrivateProperty $False