简体   繁体   English

如果用户不是某个安全组的成员,如何从 Teams 共享频道中删除用户?

[英]How do I remove a User from a Teams Shared Channel if they are not a member of a certain security group?

I'm trying to automate the removal of users from a shared channel that are not part of a dynamic security group.我正在尝试自动从不属于动态安全组的共享频道中删除用户。 I think I'm heading down the right path, but I'm relatively new to PS scripting.我认为我正朝着正确的方向前进,但我对 PS 脚本编写还比较陌生。

$securitygroupId = "The Security Group"
$channelgroupId = "The GroupId of the host AzureAD Group"
$channelname = "Name of the Shared Channel"

Get-TeamChannelUser -GroupId $channelgroupId -DisplayName $channelname |
    ForEach-Object {$channelusergroups = Get-AzureADUserMembership -ObjectId $_.UserId | Select ObjectId
                    if ($channelusergroups -NotContains $securitygroupId)
                        {Remove-TeamChannelUser -GroupId $channelgroupId -DisplayName $channelname -User $_.User
                        }
                   }

It removes the users right now even if they are in the security group.它现在删除用户,即使他们在安全组中。

I learned that if you put "-expand" after "select", the search will find the ObjectId of the security group in the pipeline.我了解到,如果在“select”之后加上“-expand”,搜索将在管道中找到安全组的 ObjectId。 Hope this helps someone else!希望这可以帮助别人! -Cheers -干杯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 您好,如何批量删除按 Teams 名称排序的成员? - Hello, how do I bulk remove members sorted by Teams names? 如何通过 PowerShell 设置 Microsoft Teams 通用频道权限 - How do I set Microsoft Teams General Channel Permissions through PowerShell 从文本文件中提取每个用户的“成员”安全组列表 - Pull each user's "Member Of" security group list from a text file 使用GUID从AD组中删除成员 - Using GUID to remove member from AD Group 如何按共享列值对CSV行进行分组和求和? - How do I group and sum CSV rows by shared column value? 如何使用Powershell从SSRS文件夹安全性中删除用户 - How to remove a user from SSRS folder security using Powershell 我想在 Powershell 7.2.4 中删除某个字符串的某些部分,我该怎么做? - I want to remove certain parts of a certain string in Powershell 7.2.4, how do I do it? 在 Format-Table 中,如何删除包含某些单词的结果? - In Format-Table, how do I remove results with certain words? 从通讯组中删除Exchange 2010的禁用成员 - Remove disabled member from distribution group for Exchange 2010 从 AD 组中删除成员而不使用模块 - Remove member from AD group without using modules
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM