MS Teams - Booking Exchange Rooms
As you might have noticed - MS Teams has changed a few times over the last year or so (in classical Microsoft fashion I'd say)
One of the features some of the users at our company have been complaining that's "not working" is scheduling meetings, on a meeting room, directly via Teams (instead of Outlook).
If you run Microsoft 365 on your business, you're by now more than aware that the way we usually configure Meeting Rooms to appear as "Locations" on Exchange is via Rooms & Resources. Basically, creating an email address, that will allow for those bookings to be made directly via name (instead of having to loop in the room email address on every meeting invite)
Issue here, is that it works on Outlook but it doesn't on Teams - which, honestly makes no sense.
After some digging and experimenting, this was the workaround I've found.
The script requires that you have a role with the necessary privileges (or GA) on MS365, and that you have Powershell 7 installed as well as admin rights on the machine you are running it (to allow for PS to import modules)
You can find guidance on how to install PS 7 on the link below,
https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.4
Script provided will:
1.Check for all the Locations & Main Locations, and prompt to create a new one if desired
2.Check for existent & Create the Room List (DL) with RoomList type, and associate it to a location
3.Query for available Rooms, and prompt to add them to the selected or newly created RoomList
# Import Exchange Online Management module (if not already loaded)
if (-not (Get-Module -Name ExchangeOnlineManagement -ListAvailable)) {
Install-Module -Name ExchangeOnlineManagement -Force
}
Import-Module ExchangeOnlineManagement
# Step 1: Prompt for Admin Email and connect to Exchange Online
$AdminEmail = Read-Host "Enter your Admin Email to log in to Exchange Online"
Write-Host "Connecting to Exchange Online..."
Connect-ExchangeOnline -UserPrincipalName $AdminEmail
# Step 2: Check for existing locations
Write-Host "Checking for existing RoomList locations..."
$ExistingRoomLists = Get-DistributionGroup | Where-Object { $_.RecipientTypeDetails -eq 'RoomList' }
if ($ExistingRoomLists.Count -gt 0) {
Write-Host "Found the following RoomList locations:" -ForegroundColor Green
$ExistingRoomLists | ForEach-Object { Write-Host "- $($_.Name) (Location: $($_.Notes))" }
} else {
Write-Host "No existing RoomList locations found." -ForegroundColor Yellow
}
# Step 3: Prompt to create a new RoomList or use an existing one
$UseExisting = Read-Host "Do you want to use an existing RoomList location? (yes/no)"
if ($UseExisting -ieq "yes") {
$RoomListAlias = Read-Host "Enter the alias of the existing RoomList to use"
$SelectedRoomList = $ExistingRoomLists | Where-Object { $_.Alias -eq $RoomListAlias }
if ($null -eq $SelectedRoomList) {
Write-Host "The specified RoomList alias was not found." -ForegroundColor Red
Disconnect-ExchangeOnline -Confirm:$false
exit
}
Write-Host "Using existing RoomList: $($SelectedRoomList.Name) (Location: $($SelectedRoomList.Notes))" -ForegroundColor Green
} else {
# Step 4: Prompt for Room List Details to create a new one
$RoomListName = Read-Host "Enter the name for the new RoomList Distribution List"
$RoomListAlias = Read-Host "Enter an alias for the RoomList"
$RoomListLocation = Read-Host "Enter the main location for the RoomList"
# Step 5: Create the RoomList Distribution List
Write-Host "Creating RoomList Distribution List..."
try {
New-DistributionGroup -Name $RoomListName -Alias $RoomListAlias -PrimarySmtpAddress "$RoomListAlias@yourdomain.com" -RoomList
Write-Host "Successfully created RoomList Distribution List: $RoomListName" -ForegroundColor Green
} catch {
Write-Host "Failed to create RoomList Distribution List: $($_.Exception.Message)" -ForegroundColor Red
Disconnect-ExchangeOnline -Confirm:$false
exit
}
# Step 6: Associate the RoomList to the Main Location
Write-Host "Associating RoomList to the main location..."
try {
Set-DistributionGroup -Identity $RoomListAlias -Notes "Location: $RoomListLocation"
Write-Host "Successfully associated RoomList with location: $RoomListLocation" -ForegroundColor Green
} catch {
Write-Host "Failed to associate RoomList with location: $($_.Exception.Message)" -ForegroundColor Red
}
}
# Step 7: Query available rooms
Write-Host "Querying available rooms..."
$AvailableRooms = Get-Mailbox -RecipientTypeDetails RoomMailbox
if ($AvailableRooms.Count -gt 0) {
Write-Host "Found the following available rooms:" -ForegroundColor Green
$AvailableRooms | ForEach-Object { Write-Host "- $($_.DisplayName) ($($_.PrimarySmtpAddress))" }
# Step 8: Prompt to add rooms to the selected or newly created RoomList
$AddRooms = Read-Host "Do you want to add these rooms to the RoomList? (yes/no)"
if ($AddRooms -ieq "yes") {
foreach ($Room in $AvailableRooms) {
try {
Add-DistributionGroupMember -Identity $RoomListAlias -Member $Room.PrimarySmtpAddress -Confirm:$false
Write-Host "Successfully added $($Room.DisplayName) to $RoomListAlias." -ForegroundColor Green
} catch {
Write-Host "Failed to add $($Room.DisplayName): $($_.Exception.Message)" -ForegroundColor Red
}
}
} else {
Write-Host "No rooms were added to the RoomList." -ForegroundColor Yellow
}
} else {
Write-Host "No available rooms found." -ForegroundColor Yellow
}
Write-Host "Operation completed." -ForegroundColor Green
# Disconnect from Exchange Online
Disconnect-ExchangeOnline -Confirm:$false
After running the script, the changes could take a while to propagate to MS Teams, but the Rooms will show on Exchange Online (not the DL nor location though)