I had an issue where certain users had the ‘RestrictedAnonymousAccess’ policy applied to them, it was only applied to certain users and was causing issues with Teams and them not being able to chat in meetings. Despite having Education_SecondaryStudent set, this group was taking preference. The only way I could remove this through Teams Admin Centre was to change them manually for each student which was not feasible. In this guide I will explain how to remove the policy from all users via Powershell.
This has been tested in Powershell 5.1
Install Teams Powershell Public Preview by running the following command
Install-Module PowerShellGet -Force -AllowClobber
Close PowerShell and reopen with elevated privileges.
Run the command to install Teams Module
Install-Module -Name MicrosoftTeams -AllowPrerelease -RequiredVersion "1.1.9-preview"
Import and update Teams Module
Import-Module MicrosoftTeams
Update-Module MicrosoftTeams
Connect to Azure
$credential = Get-Credential
Connect-MicrosoftTeams -Credential $credential
$session = New-CsOnlineSession -Credential $credential
Import-PsSession $session
To view Teams Meeting Policies assigned to your organisation use the following command
Get-CsOnlineUser | Select-Object objectid, TeamsMeetingPolicy | Group-Object TeamsMeetingPolicy
If the count is less than 100 you can use the Grant-CsTeamsMeeting policy command
Get-CsOnlineUser |? TeamsMeetingPolicy -eq "RestrictedAnonymousAccess" | Select-Object objectid | foreach {Grant-CsTeamsMeetingPolicy -Identity $_.ObjectId -PolicyName $null}
Since the count is greater than 100, we should use the newer New-CsBatchPolicyAssignmentOperation command for upto 5000 users.
$restrictedAnonymousUsers = @(Get-CsOnlineUser |? TeamsMeetingPolicy -eq "RestrictedAnonymousAccess" | %{ $_.ObjectId })
New-CsBatchPolicyAssignmentOperation -PolicyType TeamsMeetingPolicy -PolicyName $null -Identity $restrictedAnonymousUsers -OperationName "Batch unassign meeting policy"
To test this has worked, re-run the Get-CsOnlineUser command
Get-CsOnlineUser | Select-Object objectid, TeamsMeetingPolicy | Group-Object TeamsMeetingPolicy
The count has now been reduced down to 1. We can also now check the affected users in Teams admin to see if the policy has been removed.
#EdTech Network Manager, experienced in Microsoft 365, Server 2019, Intune, SCCM and anything inbetween.