If you have seen functionality like Priority Notifications arrive in Microsoft Teams, you might be tasked with disabling it for all users and enabling it for people in certain areas of the business.

In the Teams Admin Center, you can only assign policies to up to 20 users at a time:

Using Powershell to apply Messaging Policies to Teams Users

Additionally, when finding the users to assign policies to, you’ll find it is not simple to filter users based on the department or role they work in. Instead, you’ll need to manually select small numbers of people, then assign the policy to them. If you’ve created a number of policies and have more than a handful of users, this will take a long time.

Make things simpler using PowerShell

Using PowerShell to make these changes allows you to make mass-changes with relative ease. You can use the Grant-CSTeamsMessagingPolicy cmdlet to apply the policy to both individual users or multiple users at once. We’ll use that, in combination with filtering the results of Get-CSOnlineUser to do this.

First, you’ll need to install the Skype for Business Online PowerShell Module (Yes, it’s for Teams – you read that correctly). If you need to install it, you can read our guide here.

After launching a new PowerShell session, connect to Skype for Business Online using the following PowerShell:

Import-Module SkypeOnlineConnector
$Session = New-CsOnlineSession
Import-PSSession $Session  
Using Powershell to apply Messaging Policies to Teams Users

Once we’re connected, we have access to the range of PowerShell cmdlets available for management of Teams as a service, though not individual Teams themselves – to do that we need the Teams PowerShell Module.

For our purposes, all we’ll need is access to control the Teams Messaging Policies.

To grant a single user a Messaging Policy, use the Grant-CsTeamsMessagingPolicy with the Identity and PolicyName parameters

Grant-CsTeamsMessagingPolicy -Identity "<User
UPN>" -PolicyName "<Policy Name>"
Using Powershell to apply Messaging Policies to Teams Users

In the example above, we’ve granted my access to the Messaging Policy Power Users we created in our Priority Notifications article.

But what if we want to apply this en-mass? One option is to get the business to supply a list of user email addresses for each policy as a CSV file and use Import-CSV to import this.

Another option is to use existing attributes to find the right users. By using Get-CSOnlineUser you can view a list of the attributes available on each user. These include useful properties including Title, City, Manager, Description, Company, CountryorRegionalDisplayName and Department.

We’ll use Department in the example below and grant all people in the Development department the Power Users policy.

To do this, we’ll use Get-CSOnlineUser with the Filter parameter and specify {Department -eq ‘Development’}. This will retrieve all users with a department name that equals “Development”:

Get-CsOnlineUser -Filter {Department -eq 'Development'}
| Select UserPrincipalName

To make sure the information retrieved is easy to see on screen, we’ll pipe the output returned into Select and just choose to show the UserPrincipalName, which is a bit easier to judge if we’ve got the right information back:

Using Powershell to apply Messaging Policies to Teams Users

If we’re happy we’ve selected the correct users, we can then use the same cmdlet again, but this time pipes the output directly into Grant-CSTeamsMessagingPolicy:

Get-CsOnlineUser -Filter {Department -eq 'Development'}
| Grant-CsTeamsMessagingPolicy
-PolicyName "Power
Using Powershell to apply Messaging Policies to Teams Users

After granting the policy to users, it may take a few minutes for the results to show – so after waiting a few minutes we can run a slightly modified version of the first cmdlet to select users and this time filter based on the TeamsMessagingPolicy:

Get-CsOnlineUser -Filter {TeamsMessagingPolicy
-eq 'Power Users'}
| Select UserPrincipalName 

What we’re doing in the above example is retrieving all users who have the Power Users custom policy and showing their details. This should allow us to verify these users do have the policy applied:

Using Powershell to apply Messaging Policies to Teams Users


In this article, we’ve used PowerShell to apply an existing custom messaging policy to users. In this case, we are using it to make it easy to enable or disable Priority Notifications for large groups of users, based on Department.

About the Author

Steve Goodman

Technology Writer and Chief Editor for AV Content at Practical 365, focused on Microsoft 365. A 12-time Microsoft MVP, author of several technology books and regular Microsoft conference speaker. Steve works at Advania in the UK as Field Chief Technology Officer, advising business and IT on the best way to get the most from Microsoft Cloud technology.


  1. aruna

    100 users out of 3k were assigned different custom policies. Now we want to apply a new custom global wide org policy to all users except those already with custom policy . Is there any way to do that in one shot

  2. Aja

    I want to pull all Audioconferencing licensed user and assign that user DialOut Policy, any suggestion

    1. KP

      $dataSetFilePath = “C:\Users\xyz.csv”
      $dataSet = Import-Csv “$($dataSetFilePath)”
      foreach($line in $dataSet)
      $userId = $line.UserPrincipalName
      Write-Host $userId
      Grant-CsDialoutPolicy -Identity $userId -PolicyName “Add_Policy_Name_here”

  3. Paul

    Hi. Our organisation has around 3000 users globally and we are around 50% through the migration of these (by office/unit) from their existing PBX/Hosted telephone systems to Teams Calling, for external calls.

    For reporting purposes, is there a cmdlet I can run which will list those who have had Teams Calling enabled so we can generate progress charts?

  4. chad

    How do you apply a meeting policy to an Active directory security group with members in it please?

  5. Timothy Willis

    This worked great for me. Now how do I attach this new policy to the Teams license for all new user assignments going forward?

  6. Jason

    It appears you can apply up to 20,000 users now in the GUI. Still it appears to have failed when I tried for 370 users at around 150, so will have to stagger the assignments.

    1. Julian

      I have similar issues to you right now, Jason, so hunting around for more powerful options than the GUI.

      Although I can select several hundred users within the Teams interface, any number more than 20 looks like it starts to process – Teams directs me to the activity log, where I can watch it sit for 2-3 days as ‘Not Started’ It then eventually fails. This same behaviour is for 500 users, or just 21 users.

      If I select 20 at a time, and then edit those 20 in bulk, the policy changes are immediately (within 10-20 seconds) applied to the users.

  7. ML

    Can you please give me a sampe .ps1 file + .CSV to Grant-CsTeamsMeetingPolicy to bulk users?


    1. Sean

      Hi ML

      I created this to apply to a list of users on a csv. Create a csv with users principle names and make sure cell 1A has the header of UserPrincipalName , and all the users listed below.

      Import-Csv C:\teams1.csv | ForEach-Object {
      $User = Get-CsOnlineUser -Identity $_.UserPrincipalName
      Grant-CsTeamsMessagingPolicy -Identity $User.UserPrincipalName -PolicyName “EduFaculty”


      1. Peter Geipel


        Is there a way to assign a policy package to users based on AD groups? For example, I have my licenses assigned based on faculty type, student. I need to then use our AD groups for students and teachers to apply a specific Policy Package to those users based on the groups.



        1. Steve Goodman

          Batch application of policies is now available – it should be in the 1.0.5 module.


  8. Peter Hutchings

    Great! Answered a question I was l’ve been asking. Thanks!

    I’ve had zero Powershell experience and am finding myself in the thick of Office 365 Teams administration!

    I’m now looking at a way of changing the policies that are applied to certain users. For example, I have a group of users that I added to a “Test Policy” that I would now like to assign to the “Global Policy” for Teams Meeting Policy. I’ve attempted this:

    Get-CsOnlineUser -Filter {TeamsMessagingPolicy -eq ‘IT Test Policy’} | Grant-CsTeamsMessagingPolicy -PolicyName “Global (Org-wide default)”

    But it says I can only apply custom policies? So is there no way to automatically shift the users in this test policy over to the Global? Don’t really want to find each user individually and change from Test to Global.

    Thanks in advance,

    1. Rakesh Rajeev

      it is a late reply, but may be useful for someone looking for the answer still. recently I had to do the same for a set of users. assign a policy with $null and it will set the user to teh Org default.

      | Grant-CsTeamsMeetingPolicy -PolicyName $Null

      1. Duncan

        Thanks a bunch helped me!

      2. Chris

        Awesome, thank you for posting this Rakesh! For some reason, our org had random assignments of users in the AllOn and RestrictedAnonymousAccess policies, and we’re trying to consolidate those all onto Global. This is super helpful!

  9. Mel Wade

    Where can we find a list of AD parameters that work with the “filter” option

  10. Stephen Bell

    Thanks Steve much appreciated.

    Have you ever done a PowerShell script that would set caller ID based on users 100 number range
    i.e. if users URI begins with “61 7 5443 35” set users call id policy to named “AU-QLD-Call-ID”

  11. Pak Mega Place (www.pakmegaplace.com)

    Thanks, useful information 🙂

Leave a Reply