Recently one of our customers have had an issue where the ‘Get-CsUser’ command would error due to the user still being a part of a policy however the policy had been deleted already. The error will look something along the lines of:

In this instance the issue was with a hosted voicemail policy, it is always best practice to remove all users from policy’s if you decide you want to delete them. To see what policy users have applied to them you can run the following command:

Get-CsUser | Where-Object {$_.HostedVoicemailPolicy -match “^2”

In order to remove these policies from the accounts you will simply need to run the following command (of course replace the name of the policy to the one applied to your user accounts):

Get-CsUser | Where-Object {$_.<policy name> -match “^14”} | Grant-CsExternalAccessPolicy -PolicyName $null

Hope this helps!