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

%3CLINGO-SUB%20id%3D%22lingo-sub-786318%22%20slang%3D%22en-US%22%3EPowerShell%20script.%20List%20of%20500%20users%20and%20conference%20room%20ownership%20(managerment)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-786318%22%20slang%3D%22en-US%22%3E%3CP%3EHey%20Guys%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20list%20of%20500%20or%20so%20users%20who%20i%20want%20to%20find%20out%20which%20conference%20rooms%20they%20own%2C%20or%20are%20listed%20as%20manager%20of.%20There%20are%20about%2017K%20conference%20room%20mailboxes.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20tried%20many%20variations%20of%20the%20following%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%23Import%20primary%20SMTPs%20and%20get%20the%20recipient%20objects%20for%20them%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24userv%20%3D%20(Import-Csv%20SportsRequest.csv).primarysmtpaddress%20%7C%20get-recipient%20(This%20list%20has%20my%20users%20where%20their%20identity%20is%20a%20list%20of%20PrimarySmtpAddresses).%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%23get%20all%20remoteroommailbox%20objects%20and%20filter%20to%20only%20ones%20where%20the%20CSV%20matched%20an%20owner%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24relevantrooms%20%3D%20Get-Recipient%20-RecipientTypeDetails%20RemoteRoomMailbox%20%7C%20Where%20%3CSTRONG%3E%7B%24userv.identity%20-contains%20%24_.manager%7D%3C%2FSTRONG%3E%26nbsp%3BThis%20is%20where%20i%20am%20having%20trouble%2C%20whenever%20i%20run%20the%20command%20it%20just%20skips%20the%20user.identity%20(or%20user.primarysmtpaddress%2C%20i%20tried%20both)%20portion%20and%20runs%20Get-Recipient%20for%20the%20entire%20tenant%20and%20does%20not%20match%20the%20room%20mailboxes%20against%20my%20list%20of%20users%20in%20the%20variable%20%24Userv%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%23export%20something%20to%20csv%3C%2FP%3E%3CP%3E%24relevantrooms%20%7C%20select%20identity%2Cprimarysmtpaddress%2Cmanager%20%7C%20export-csv%20-notype%20SportsRooms.csv%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20ideas%3F%20I%20think%20this%20shouldn't%20be%20as%20hard%20as%20it%20is%2C%20but%20well%20i%20am%20not%20Mr.%20PowerShell.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERobert%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-786318%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExchange%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-786828%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20script.%20List%20of%20500%20users%20and%20conference%20room%20ownership%20(managerment)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-786828%22%20slang%3D%22en-US%22%3E%3CP%3EWhit%20that%20number%20of%20objects%2C%20you're%20better%20off%20exporting%20the%20complete%20list%20of%20room%20mailboxes%20along%20with%20the%20corresponding%20properties%20to%20a%20CSV%2C%20then%20using%20Excel%20to%20do%20a%20lookup%20for%20matching%20users%20from%20your%20other%20CSV%20file.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EOr%2C%20you%20can%20use%20server-side%20filtering%20based%20on%20the%20Manager%20attribute%2C%20but%20for%20that%20you%20need%20to%20prepare%20a%20list%20of%20DNs%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3EGet-Recipient%20-RecipientTypeDetails%20RoomMailbox%20-Filter%20%7BManager%20-eq%20%22CN%3Dmanager%2COU%3Dtenant.onmicrosoft.com%2COU%3DMicrosoft%20Exchange%20Hosted%20Organizations%2CDC%3DEURPR03A001%2CDC%3Dprod%2CDC%3Doutlook%2CDC%3Dcom%22%7D%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-786829%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20script.%20List%20of%20500%20users%20and%20conference%20room%20ownership%20(managerment)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-786829%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F58%22%20target%3D%22_blank%22%3E%40Vasil%20Michev%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20the%20response.%20As%20i%20always%20i%20appreciate%20it.%20But%20what%20i%20dont%20understand%20is%20why%20my%20powershell%20script%2Fcommands%20arent%20working.%20Can%20you%20help%20me%20to%20fix%20the%20command%20itself%3F%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERobert%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-787366%22%20slang%3D%22en-US%22%3ERe%3A%20PowerShell%20script.%20List%20of%20500%20users%20and%20conference%20room%20ownership%20(managerment)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-787366%22%20slang%3D%22en-US%22%3E%3CP%3EWithout%20seeing%20the%20full%20solution%20including%20the%20CSV%20file%20I%20cannot%20be%20sure.%20I'd%20suggest%20reviewing%20the%20actual%20values%20stored%20within%20the%20different%20variables%2C%20make%20sure%20there%20are%20no%20empty%20values%20and%20that%20they%20can%20be%20compared%20against%20each%20other%20and%20so%20on.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
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. 

 

Thanks, 

 

Robert 

 

3 Replies
Highlighted

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"}

Highlighted

@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? 

 

Thanks, 

 

Robert 

Highlighted

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.