Displaying all of your Room Mailboxes in Workplace365 utilizing the Graph REST API

Displaying all of your Room Mailboxes in Workplace365 utilizing the Graph REST API One of many recurring questions you see requested in Boards round EWS is the power to see all of the Room Mailboxes in Alternate. That is fairly cheap request that hasn’t actually had a straightforward reply previously there are RoomLists however these required setup and ongoing upkeep and coordination  which might be troublesome. For those who the place utilizing OnPrem alternate then as an alternative of utilizing EWS you might simply use LDAP to lookup Energetic Listing instantly (as properly all know AD is the listing service for Alternate) eg again in 2007 I created this

With Workplace365 you do not have LDAP entry to the listing and the Graph API whereas its good does not supply entry to the actual property on a Person or Listing Object that may will let you inform if that object has an related Room (or group or shared mailbox). The excellent news nonetheless is the Graph API  now offers you the power to tug all of the Room Mailbox utilizing findrooms operation

I’ve added assist for this to my Exch-Relaxation Module within the Powershell gallery  so now you can get this with a script like the next utilizing the Beta namespace

$Token = Get-AccessToken -MailboxName -ClientId 5471030d-f311-4c5d-91ef-74ca885463a7 -redirectUrl urn:ietf:wg:oauth:2.0:oob -ResourceURL -beta  
Discover-Rooms -Mailbox -AccessToken $Token

and it returns a easy record of your Room mailboxes like

You would additionally pipe the outcomes into one other script to seek out the usages of these room mailboxes for the subsequent day. To do that I take advantage of the Get-CalendarView cmdlet which makes a request for the subsequent 24 hours of appointments utilizing a CalendarView as documented in (for this to work it’s essential have rights on all of the Rooms you wish to report on else you’ll get a ‘Service Unavailable’ error)

$MailboxName = ""
$Token = Get-AccessToken -MailboxName $MailboxName -ClientId 5471030d-f311-4c5d-91ef-74ca885463a7 -redirectUrl urn:ietf:wg:oauth:2.0:oob -ResourceURL -beta
$rptCollection = @()
Discover-Rooms -Mailbox $MailboxName -AccessToken $Token | foreach-object foreach-object Choose Room,Organizer,Topic,Begin,Finish
$rptObj.Room = $RoomAddress
$rptObj.Organizer = $_.organizer.emailAddress.title
$rptObj.Topic = $_.topic
$rptObj.Begin = [DateTime]::Parse($_.begin.datetime).ToString("yyyy-MM-ddTHH:mm:ss")
$rptObj.Finish = [DateTime]::Parse($_.finish.datetime).ToString("yyyy-MM-ddTHH:mm:ss")
$rptCollection += $rptObj


You possibly can then flip the gathering right into a CSV or HTML file as you want

This full pattern with HTML output and the module supply code might be discovered on GitHub right here (pattern is in samples)