Forum Discussion

Daniel Smith's avatar
Daniel Smith
Copper Contributor
Mar 23, 2020

PowerShell in Teams for Members of a Messaging Policy

Dear All

 

I can use PowerShell to see what Messaging Policy a single user belongs to:

 

Get-CsOnlineUser -Identity jbloggs | Format-Table UserPrincipalName, TeamsMessagingPolicy

 

How do I see all the users that belong to a particular Messaging Policy, for example, a messaging policy called 'Students - No Chat'?

 

I have a policy which I am unable to delete because it says one or more users are still assigned to it but I don't know who they are to remove them. 

 

Many thanks for your help

 

Dan

  • Hi,

     

    This should work:

    Get-CsOnlineUser | Where-Object {$_.TeamsMessagingPolicy -eq "Students - No Chat"} | fl Identity,TeamsMessagingPolicy

     

     

     

    And to set it back to Global use:

    Get-CsOnlineUser | Where-Object {$_.TeamsMessagingPolicy -eq "Students - No Chat"} | Grant-CsTeamsMessagingPolicy -PolicyName $null

Resources