How to export a list of upcoming bookings from your room calendars on Microsoft Exchange
This article explains how to export every upcoming booking across your rooms and desks to a spreadsheet, and which requirements are necessary.
AskCody shows the bookings that live in your room and desk calendars in Microsoft Exchange Online. Central and All Bookings display them across all locations for any date you pick, one day at a time, and Insights reports on how your rooms have been used over the past 13 months. Neither produces a list of bookings for a future period. That list lives in the room calendars themselves, and this article shows an IT Admin how to pull it into a CSV file that opens in Microsoft Excel. It takes about 15 minutes the first time and a minute each time after that.
If you are looking for historical usage rather than upcoming bookings, read How to export Insights data.
Requirements for exporting upcoming bookings
Software requirements
- PowerShell 7 (Windows PowerShell 5.1 also works)
- Microsoft.Graph.Authentication and Microsoft.Graph.Calendar, the Microsoft Graph PowerShell modules
- ExchangeOnlineManagement, the Exchange Online PowerShell module
The permissions required
- Exchange Administrator (or Global Administrator) in Microsoft 365, for granting read access to the room calendars in step 2
- Calendars.Read.Shared (Delegated), the Microsoft Graph permission you consent to when you sign in in step 3
- Reviewer access on each room calendar for the account that runs the export
Note: Every command in this article only reads your calendars. Nothing is created, changed, or deleted, and the Reviewer access can be removed again once you have your export.
By running these commands, AskCody will not hold or read your mailbox data, which is why the export runs against Exchange Online in your own tenant rather than from the AskCody Portal.
Step 1: Install the modules
You only do this once per computer.
- Open PowerShell.
- Run the three commands below, one at a time.
Install-Module Microsoft.Graph.Authentication -Scope CurrentUser -ForceInstall-Module Microsoft.Graph.Calendar -Scope CurrentUser -ForceInstall-Module ExchangeOnlineManagement -Scope CurrentUser -Force
Note: If a later command reports that Connect-MgGraph or Get-MgUserCalendarView is "not recognized", the modules are not installed in the PowerShell you are using. Repeat this step in that window.
Step 2: Give your account read access to the room calendars
Room calendars are not readable by other accounts by default, so an Exchange Administrator grants Reviewer (read only) access once per room. The commands below collect every room mailbox in your tenant, find the name of each room's calendar folder, and grant the access. The folder name is looked up rather than typed, because a mailbox set to another language names the folder differently (for example, Kalender rather than Calendar).
- In PowerShell, connect to Exchange Online and sign in as an Exchange Administrator:
Connect-ExchangeOnline
- Collect the room mailboxes and grant Reviewer access to the account that will run the export. Replace your.account@yourdomain.com with that account.
$rooms = (Get-EXOMailbox -RecipientTypeDetails RoomMailbox -ResultSize Unlimited).PrimarySmtpAddress foreach ($room in $rooms) { $cal = (Get-MailboxFolderStatistics -Identity $room -FolderScope Calendar | Where-Object { $_.FolderType -eq "Calendar" }).Name Add-MailboxFolderPermission -Identity "$($room):\$cal" -User "your.account@yourdomain.com" -AccessRights Reviewer }
Each room returns one line showing the folder name, the user, and {Reviewer}.
Note: If you only need some of your rooms, replace the first line with a list of addresses, for example: $rooms = @("room-a@yourdomain.com", "room-b@yourdomain.com")
To remove the access afterwards (if needed), run Remove-MailboxFolderPermission with the same Identity and User values.
Step 3: Sign in to Microsoft Graph and set the period
- Sign in to Microsoft Graph with the account that was granted access in step 2. A browser window opens for sign-in. The first time, Microsoft asks you to consent to the Calendars.Read.Shared permission.
Connect-MgGraph -Scopes "Calendars.Read.Shared" -NoWelcome
- Set the period and the time zone. The example covers six months in Eastern time. Adjust the two dates, the offset, and the time zone name to your own location (for example, "Romance Standard Time" and +02:00 for Central European Time).
$start = "2026-09-22T00:00:00-04:00" $end = "2027-03-22T00:00:00-04:00" $tz = 'outlook.timezone="Eastern Standard Time"' $out = Join-Path ([Environment]::GetFolderPath("Desktop")) "room-bookings.csv"
Note: $out resolves to your Windows Desktop, including a Desktop that OneDrive has moved. It also works on macOS.
Step 4: Export the upcoming bookings to a CSV file
- Confirm that one room returns data before exporting all of them. Replace the address with one of your rooms.
$events = Get-MgUserCalendarView -UserId "room-a@yourdomain.com" -StartDateTime $start -EndDateTime $end -All -Headers @{ Prefer = $tz } $events.Count
Check: The count should match roughly what you expect for that room over the period. A count of 0 with no red error text means one of the values from step 3 is blank. A red error mentioning access or authorization means the Reviewer access from step 2 has not reached that room yet. Wait a few minutes and try again.
- Pull every booking for every room into one file on your Desktop, sorted by room and start time. PowerShell prints nothing when this succeeds.
$rooms | ForEach-Object { $room = $_ Get-MgUserCalendarView -UserId $room -StartDateTime $start -EndDateTime $end -All -Headers @{ Prefer = $tz } | Select-Object @{n="Room";e={$room}}, Subject, @{n="Start";e={$_.Start.DateTime}}, @{n="End";e={$_.End.DateTime}}, @{n="Organizer";e={$_.Organizer.EmailAddress.Name}}, @{n="OrganizerEmail";e={$_.Organizer.EmailAddress.Address}} } | Sort-Object Room, Start | Export-Csv $out -NoTypeInformation -Encoding UTF8
- Confirm the file has rows in it.
Import-Csv $out | Measure-Object | Select-Object Count Import-Csv $out | Select-Object -First 3 | Format-Table
Check: The count should be above 0 (for a single room it equals $events.Count from the previous step), and the three rows should show Room, Subject, Start, End, Organizer and OrganizerEmail.
- Open room-bookings.csv from your Desktop in Microsoft Excel. If the columns do not separate correctly, read How to correctly open exported CSV files in Excel.
What the export contains
- One row per booking, per room. A recurring meeting returns one row for each occurrence in the period, which is what you want in a forward-looking list.
- Start and End in the time zone you set in step 3.
- On many room calendars, Exchange replaces the meeting subject with the organizer's name. This is the standard room mailbox setting, so the Organizer and OrganizerEmail columns are the reliable ones.
- Bookings the room has declined are not on the room calendar and therefore not in the export.
To group the export by location, add a column in Excel that maps each room address to its office or floor. The room list with locations is available in the AskCody Portal under Admin Center > Account > Locations.
Running the export again
Open PowerShell, run the $rooms line from step 2 (Exchange sign-in is only needed if you are granting new access), then run step 3 and step 4. The Reviewer access from step 2 stays in place until you remove it.