by

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 http://gsexdev.blogspot.com.au/2007/04/webservice-to-find-room-and-equipment.html.

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 https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/user_findrooms

I’ve added assist for this to my Exch-Relaxation Module within the Powershell gallery https://www.powershellgallery.com/packages/Exch-Relaxation  so now you can get this with a script like the next utilizing the Beta namespace

$Token = Get-AccessToken -MailboxName mailbox@area.com -ClientId 5471030d-f311-4c5d-91ef-74ca885463a7 -redirectUrl urn:ietf:wg:oauth:2.0:oob -ResourceURL graph.microsoft.com -beta  
Discover-Rooms -Mailbox mailbox@area.com -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 https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/user_list_calendarview (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 = "gscales@datarumble.com"
$Token = Get-AccessToken -MailboxName $MailboxName -ClientId 5471030d-f311-4c5d-91ef-74ca885463a7 -redirectUrl urn:ietf:wg:oauth:2.0:oob -ResourceURL graph.microsoft.com -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


$rptCollection

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 https://github.com/gscales/Exch-Relaxation (pattern is in samples)