我正在尝试执行批量操作以将 Azure AD 组的组写回状态设置为“安全”,但无法使用 powershell 实现此目的。
有没有可能使用 powershell 来自动执行此操作?
需要更新的所需字段:
尝试使用 Set-Azure AD 命令并设置 -securityenabled=$true
您可以使用
模块来启用 Azure AD 安全组的组写回状态。Microsoft.Graph.Beta
如果您没有安装该模块,请运行以下命令来安装它:
Install-Module Microsoft.Graph.Beta -AllowClobber
我有一个名为
SriGroup
的 Azure AD 组,组写回状态为 无写回,如下所示:
现在,我运行下面的 PowerShell 脚本将上述组的组写回状态设置为 Security:
Import-Module Microsoft.Graph.Beta.Groups
Connect-MgGraph -Scopes "Group.ReadWrite.All"
$params = @{
writebackConfiguration = @{
isEnabled = $true
onPremisesGroupType = "universalSecurityGroup"
}
}
$groupId = "xxxxxxx-xxxx-xxx-xxxxxxxx"
Update-MgBetaGroup -GroupId $groupId -BodyParameter $params
回复:
当我在门户中检查相同内容时,组写回状态成功更改为Security,如下所示:
要执行将组写回状态设置为“安全”的批量操作,您可以使用以下修改后的脚本:
Import-Module Microsoft.Graph.Beta.Groups
Connect-MgGraph -Scopes "Group.ReadWrite.All"
$params = @{
writebackConfiguration = @{
isEnabled = $true
onPremisesGroupType = "universalSecurityGroup"
}
}
$groupIds = @("id1", "id1", "id3")
foreach ($groupId in $groupIds) {
Update-MgBetaGroup -GroupId $groupId -BodyParameter $params
}
运行上述脚本时请确保使用最新 PowerShell 版本。