Teams禁止指定用户私下聊天

前段时间,微软的Teams切换了新的管理员界面,相信大家的有所了解的了,而且现在他们还不断的添加新的可控策略让我们更加方便容易的管理。但有点大家要注意了,我发现切换到新的管理员控制平台之后,有些之前我们 在旧控制平台上的设置被重写了,没有继承到新的控制平台上。打个比方,下图是旧的控制平台,你可以看到我们可以选择直接把学生或者老师的私下聊天功能禁止,但我发现到新的平台上,却没有继承这个配置下来。

A screenshot of a social media post

Description automatically generated

好吧,既然知道问题所在,那就好解决了,先到管理员平台上切换到新的面板模式(其实我一直是用新版的,毕竟即使不习惯,但反正早晚都要用,不如早用头痛拉,哈哈)。 之所以切换到旧平台,是因为想截图把我们旧的Teams配置给大家看来更好的阐述问题所在拉。

A screenshot of a cell phone

Description automatically generated

按下图所示点击Teams的新管理界面.

A screenshot of a social media post

Description automatically generated

点击Message Policy之后再选择Global.(要注意的是当切换到新的管理员平台,所有用户就默认assign给Global Policy, 没有再细分老师学生了。)

A screenshot of a cell phone

Description automatically generated

默认情况下,Global策略上的Chat是开启的,如果之前你在旧管理员界面上开启chat功能给老师,禁止chat功能给学生,那么现在出现的问题就是所有的用户都有了这个私下聊天功能了。这是为什么学生突然又有了私下聊天功能的原因。

A screenshot of a cell phone

Description automatically generated

现在我们需要做的是开启一条独立的message策略给指定的用户,像我们这边的需求就是学生。所以在Message Policy上新建一条名为“Test policy for student”之后把chat的功能关掉。

A screenshot of a computer

Description automatically generated

之后回到O365的管理员界面,在Groups里面新建一个security group,这里改名成“test group from James”.

A screenshot of a cell phone

Description automatically generated

之后在member上把所需要对应policy message的人加进去security group里面,你出来可以选择加入个人,也可以加入对应AD已经存在的组,这是为什么我要新建一个security group。

A screenshot of a cell phone

Description automatically generated

现在你要用powershell把安全组关联给message policy上。首先用管理员身份打开powershell。

A screenshot of a cell phone

Description automatically generated

输入以下命令和管理员账号来连接Azure AD.

Connect-AzureAD

A screenshot of a cell phone

Description automatically generated

输入以下命令来导入skype模块.

Import-Module SkypeOnlineConnector

A screenshot of a cell phone

Description automatically generated

输入$credential = Get-Credential

A screenshot of a cell phone

Description automatically generated

输入以下命令并且登陆Office365的管理员账号

$sfboSession = New-CsOnlineSession -Credential $credential

A screenshot of a cell phone

Description automatically generated

输入Import-PSSession $sfboSession

A screenshot of a cell phone

Description automatically generated

输入$group = Get-AzureADGroup -SearchString “这里输入刚刚新建的security group的名称“。

A screenshot of a cell phone

Description automatically generated

输入$members = Get-AzureADGroupMember -ObjectId $group.ObjectId -All $true | Where-Object {$_.ObjectType -eq “User”}

A screenshot of a cell phone

Description automatically generated

输入$members | ForEach-Object {Grant-CsTeamsMessagingPolicy -PolicyName “输入在Teams管理员界面上新建的message policy的名字” -Identity $_.UserPrincipalName}

A screenshot of a cell phone

Description automatically generated

下图就是成果了,你可以看到chat的那个icon不见了,从而实现禁止学生私下聊天功能。 要注意的是,命令生效时间要好几个小时的,所以耐心点,喝杯咖啡,吃个糕点再回来看成功,因为我发现无论任何改动,通过powershell改的Teams配置无论如何都要好几个小时才生效的,耐心点吧各位。话说新版本的管理员界面虽然重置了旧的配置而增加了工作量,但在新平台上我们有更加高可控的策略可以分发出来,所以大家有时间还是上去看看吧。

A screenshot of a social media post

Description automatically generated