Regarding the CsApplicationAccessPolicy in Teams powershell

Wang, Qinjie 105 Reputation points
2025-08-05T08:38:14.23+00:00

Hi, Teams,

Currently, many employees in our organization use Teams. We have developed a Teams bot app and would like to assign the CsApplicationAccessPolicy to a specific group of users (around 20,000 to 30,000 people). According to the documentation, this policy can be assigned to individual users or set as a global policy. However, after discussion, we believe that applying the policy globally is too risky in case of any issues, while assigning it individually to tens of thousands of users is not only a huge workload but also difficult to maintain. Therefore, we are looking for a more manageable solution.

Specifically, we would like to know if it is possible to assign this policy to a user group, similar to group management in Entra apps, so that we can manage access more efficiently and effectively.

If there is a solution or method for this, could you please provide detailed guidance? I am not very familiar with Teams PowerShell commands, so step-by-step instructions would be greatly appreciated.

Microsoft Teams | Development
{count} votes

Accepted answer
  1. Steven-N 5,480 Reputation points Microsoft External Staff Moderator
    2025-08-05T11:50:09.2433333+00:00

    Hi Wang, Qinjie

    Thanks for reaching out to Microsoft Q&A forum support 

    Based on your description, I understand that your organization has built a Teams bot app and you're trying to assign the CsApplicationAccessPolicy to a large group of users, somewhere between 20,000 to 30,000 people. You've ruled out applying the policy globally due to the risk of widespread impact if something goes wrong and assigning it individually to each user is understandably too time-consuming and hard to maintain. 

    The issue arises from the limitations in how CsApplicationAccessPolicy can be assigned. While Microsoft officially supports global and per-user assignments, these options do not scale well for large user bases. Global assignment affects all users and can introduce unintended consequences, while individual assignment requires significant administrative effort and lacks flexibility for ongoing management. 

    So, in this context, from my perspective view, you can try to a more manageable solution is to assign the policy to a group using PowerShell by following this instruction: 

    1.Create the affective dynamic group 

    Use Microsoft Entra ID (formerly Azure AD) to create a security group or Microsoft 365 group that includes the target users. 

    2.Assign the Policy via PowerShell 

    This is the PowerShell script on my testing environment, you can try to see if it works:

    Install-Module -Name PowerShellGet -Force -AllowClobber
    Install-Module -Name MicrosoftTeams -Force -AllowClobber
    Connect-MicrosoftTeams
    $groupName = "YourGroupName"
    $policyName = "YourPolicyName"
    
    Grant-CsApplicationAccessPolicy -Group $groupName -PolicyName $policyName
    Get-CsApplicationAccessPolicy -Identity $policyName
    Get-CsOnlineUser -Filter {ApplicationAccessPolicy -eq $policyName} 
    

    Note: You have to check this syntax of your group as:
    User's image Or you can read here for more information: Grant-CsApplicationAccessPolicy (MicrosoftTeams) | Microsoft Learn 

    You may try the approach mentioned above to see if it resolves the issue. However, please note that success is not guaranteed, as the script was executed in my own environment. Differences between our environments could lead to unexpected behavior. If you have any updates or need further assistance, feel free to let me know in the comments section below. 

    Hope my answer will help you 


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".     

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


1 additional answer

Sort by: Most helpful
  1. Admin LTM Ltd 0 Reputation points
    2025-08-05T12:28:09.6466667+00:00

    Hi,

    Thank you for the detailed answer and script! I’m planning to try this group assignment method for CsApplicationAccessPolicy in our environment. Could you please confirm if this works in all tenants or only specific Microsoft 365/Teams licensing plans? Also, any tips for monitoring or troubleshooting policy assignments to groups? Thanks in advance!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.