PowerShell script. List of 500 users and conference room ownership (managerment)

Frequent Contributor

Hey Guys, 


I have a list of 500 or so users who i want to find out which conference rooms they own, or are listed as manager of. There are about 17K conference room mailboxes. 


I have tried many variations of the following: 


#Import primary SMTPs and get the recipient objects for them


$userv = (Import-Csv SportsRequest.csv).primarysmtpaddress | get-recipient (This list has my users where their identity is a list of PrimarySmtpAddresses). 


#get all remoteroommailbox objects and filter to only ones where the CSV matched an owner


$relevantrooms = Get-Recipient -RecipientTypeDetails RemoteRoomMailbox | Where {$userv.identity -contains $_.manager} This is where i am having trouble, whenever i run the command it just skips the user.identity (or user.primarysmtpaddress, i tried both) portion and runs Get-Recipient for the entire tenant and does not match the room mailboxes against my list of users in the variable $Userv


#export something to csv

$relevantrooms | select identity,primarysmtpaddress,manager | export-csv -notype SportsRooms.csv


Any ideas? I think this shouldn't be as hard as it is, but well i am not Mr. PowerShell. 






3 Replies

Whit that number of objects, you're better off exporting the complete list of room mailboxes along with the corresponding properties to a CSV, then using Excel to do a lookup for matching users from your other CSV file.


Or, you can use server-side filtering based on the Manager attribute, but for that you need to prepare a list of DNs:


Get-Recipient -RecipientTypeDetails RoomMailbox -Filter {Manager -eq "CN=manager,OU=tenant.onmicrosoft.com,OU=Microsoft Exchange Hosted Organizations,DC=EURPR03A001,DC=prod,DC=outlook,DC=com"}

@Vasil Michev 


Thanks for the response. As i always i appreciate it. But what i dont understand is why my powershell script/commands arent working. Can you help me to fix the command itself? 





Without seeing the full solution including the CSV file I cannot be sure. I'd suggest reviewing the actual values stored within the different variables, make sure there are no empty values and that they can be compared against each other and so on.