PowerShell script sample - Create and assign a messaging policy
Use this PowerShell script to create a messaging policy in Microsoft Teams and assign it to users.
For more information about using this PowerShell script, see Quick start - Teams for Education.
This script uses the Grant-CsTeamsMessagingPolicy cmdlet which is in the Skype for Business Online PowerShell module. See Teams PowerShell overview to learn more about managing Teams using PowerShell.
Before you start
Download and install the Skype for Business Online PowerShell module, and then restart your computer if prompted.
To lean more, see Manage Skype for Business Online with Office 365 PowerShell.
Sample script
<#
.SYNOPSIS
This script creates a messaging policy in Teams and assigns it to users.
.DESCRIPTION
Use this script to create a messaging policy and assign it to users in your organization.
#>
$dataSetFilePath = "<csv file with user ids for newly provisioned students> "
$dataSet = Import-Csv "$($dataSetFilePath)" -Header UserId –delimiter ","
foreach($line in $dataSet)
{
$userId = $line.UserId
Write-Host $userId
Grant-CsTeamsMessagingPolicy -PolicyName "<<PolicyName for a policy created with Chat Off>>" -Identity $userId
}
Note
You can also assign a messaging policy directly to users at scale through a batch policy assignment or to a group that the users are members of. For more information see Assign policies to large sets of users in your school and Assign policies to your users in Teams.
Phản hồi
https://aka.ms/ContentUserFeedback.
Sắp ra mắt: Trong năm 2024, chúng tôi sẽ dần gỡ bỏ Sự cố với GitHub dưới dạng cơ chế phản hồi cho nội dung và thay thế bằng hệ thống phản hồi mới. Để biết thêm thông tin, hãy xem:Gửi và xem ý kiến phản hồi dành cho