控制Microsoft Teams统一组上的AllowToAddGuests值

时间:2019-05-31 13:53:49

标签: powershell

我正在尝试在统一组级别上控制团队的来宾访问。

我尝试关注本文,但似乎有些变量(例如$SettingID)没有值:

https://techcommunity.microsoft.com/t5/Microsoft-Teams/Allow-or-Block-Guest-Users-from-a-Specific-Team-in-Microsoft/td-p/175918

import-module azureadpreview
connect-azuread

$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session -DisableNameChecking

$GroupID = get-unifiedgroup -Identity <smtpaddress> | Select-Object -ExpandProperty ExternalDirectoryObjectId
$SettingID = Get-AzureADObjectSetting -TargetType Groups -TargetObjectID $GroupID | select-object -expandproperty ID
remove-azureadobjectsetting -id $settingid -targettype Groups -TargetObjectID $GroupID
$template = Get-AzureADDirectorySettingTemplate | ? {$_.displayname -eq "group.unified.guest"}
$settingsCopy = $template.CreateDirectorySetting()
$settingsCopy["AllowToAddGuests"]=$False
New-AzureADObjectSetting -TargetType Groups -TargetObjectId $groupID -DirectorySetting $settingsCopy

从我看到的情况来看,该脚本从$settingsid行开始失败。这个变量给我一个Null值的结果。

1 个答案:

答案 0 :(得分:0)

问题出在AzureAD模块上,该设置仅在AzureADPreview上可用。