Forum Discussion
Ethan Stern
Mar 04, 2020Iron Contributor
Powershell script to find out Teams policies by users
Hey everyone, do you know if there is a way to run a script to find what Teams policies are assigned to what user? We have a private channel policy in place- I would like to find out a list of users...
Timon-O
Apr 06, 2021Copper Contributor
Just to let you know, works without code as well by using the filter option (click on "Users" in the left navigation then on the filter symbol and add the condition).
https://admin.teams.microsoft.com/users
(screenshot as an example)
I hope it helps.
- NikkiChapple_Oct 18, 2021Iron ContributorThe filter only works is the polices have been directly assigned. If the user inherits a policy from being in a group then they do not show up in the results
- SebCerazyFeb 21, 2023Iron Contributor
Get-CsUserPolicyAssignment : Cannot bind argument to parameter 'Identity' because it is an empty string. At C:\PSScripts\teams_assigned-policies.ps1:17 char:58 + ... $UserPolicies = Get-CsUserPolicyAssignment -Identity $User.ObjectId + ~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Get-CsUserPolicyAssignment], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Get-CsUserPolicyAssignment
Also no data is presented in csv at all for any user (all users have the policies assigned by group membership)
- SanatKMahapatraJul 16, 2021Copper ContributorTimon-O
Please let me know how do you export the results to excel or CSV after applying the Filter on Teams Admin Center.
Regards
Sanat- Dlewis-79Jul 19, 2021Brass ContributorHi Sanat,
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- SanatKMahapatraJul 19, 2021Copper ContributorJohnLockett Dlewis-79 .. Thank you for the details and confirmation, it's really helpful.
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.