Forum Discussion
Powershell script to find out Teams policies by users
You don't there isn't an option in Teams Admin Center... thats why the about PowerShell is so useful.
Note - some of the properties in the above PS are not exported so you may have to add on TeamsAppPermissionPolicy.
Regards,
Damian
I have only 1 query, It took 2.5+ days and the query was still running which collected over 38000+ User objects, however, I had to cancel as it entered today production hours.
Is there any way to limit or place a condition like CountryCode or ExtensionAttribute or CustomAttribute to pull a more small and specific report.
- JohnLockettJul 19, 2021Copper Contributor
Yes, you can update the top of the script to use a filter and select the attributes you want to filter on. I would suggest you query some of your users and verify that the Teams PS Module sees those attributes before trying it. For example:
Get-CsOnlineUser -Filter {CountryAbbreviation -eq "US"}
OR
Get-CsOnlineUser -Filter {City -eq "Phoenix"}
OR
Get-CsOnlineUser -Filter {(City -eq "Dallas") -or (City -eq "Phoenix")}
- SanatKMahapatraJul 20, 2021Copper ContributorThank you so much Dlewis-79 & JohnLockett for the inputs, I will reduce the amount of information needed for the first complete run even though I need all the attributes in the Info section of the script. Will apply the Filters to the Get-CSOnlineUser command.
Cheers!
- Dlewis-79Jul 19, 2021Brass Contributor
SanatKMahapatra wow that a long time. depending on what information you want to return in the excel you could limit the $Info = "" | Select to reduce the content that is returned?
I need to limit my next run by office/location but I haven't had the time to rework the PS yet to do that. But looking quickly you could add a | where {$_.CountryOrRegionDisplayName -eq "xxxx"} to the end of the $TeamsUsers = Get-CsOnlineUser | Select-Object section. That might work or use the CountryAbbreviation property instead.