用于启用 Azure AD 安全组的组写回状态的 Powershell 命令

问题描述 投票:0回答:1

我正在尝试执行批量操作以将 Azure AD 组的组写回状态设置为“安全”,但无法使用 powershell 实现此目的。

有没有可能使用 powershell 来自动执行此操作?

需要更新的所需字段:

尝试使用 Set-Azure AD 命令并设置 -securityenabled=$true

azure azure-active-directory azure-powershell
1个回答
0
投票

您可以使用

Microsoft.Graph.Beta
模块来启用 Azure AD 安全组的组写回状态。

如果您没有安装该模块,请运行以下命令来安装它:

Install-Module  Microsoft.Graph.Beta  -AllowClobber

我有一个名为

SriGroup
的 Azure AD 组,组写回状态为 无写回,如下所示:

enter image description here

现在,我运行下面的 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

回复:

enter image description here

当我在门户中检查相同内容时,组写回状态成功更改为Security,如下所示:

enter image description here

要执行将组写回状态设置为“安全”批量操作,您可以使用以下修改后的脚本:

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 版本。

参考: 更新-MgBetaGroup(Microsoft.Graph.Beta.Groups)

© www.soinside.com 2019 - 2024. All rights reserved.