Skip to content

Latest commit

 

History

History
60 lines (47 loc) · 2.38 KB

File metadata and controls

60 lines (47 loc) · 2.38 KB
title PowerShell script sample - Create & assign messaging policy
ms.author mikeplum
author MikePlumleyMSFT
manager serdars
ms.topic article
ms.reviewer ritikag
ms.date 09/11/2018
ms.service msteams
audience admin
description Use this PowerShell script to create a messaging policy in Teams and assign it to users in your organization.
f1.keywords
NOCSH
ms.localizationpriority medium
search.appverid MET150
ms.collection
M365-collaboration
appliesto
Microsoft Teams
ms.custom seo-marvel-mar2020

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.