如何在 powershell 中或使用 Graph API 将所有者添加到 Azure 权利管理目录?

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

我正在尝试将目录所有者添加到 Azure 身份管理中的目录中。这似乎没有任何地方记录。我已经尝试直接使用 PS 图形模块和图形 API (PATCH /identityGovernance/entitlementManagement/catalogs/{id}) 来尝试不同的请求主体,但无论属性如何,补丁调用始终返回 204。

例如:

$body = @{
@{
            "@odata.type" = "#microsoft.graph.singleUser"
            userId = $userId
        }
}
Update-MgEntitlementManagementCatalog -AccessPackageCatalogId $id -BodyParameter $body

有什么办法可以做到这一点吗?或者在门户中手动是唯一的选择吗?

azure powershell microsoft-graph-api identity-management azure-identity
1个回答
0
投票

我有一个名为

DemoCatalog
的目录,没有分配目录所有者,如下所示:

enter image description here

要使用 MS Graph PowerShell 将所有者添加到 Azure 权利管理目录,您可以使用以下脚本:

Connect-MgGraph -Scopes "EntitlementManagement.ReadWrite.All"
Import-Module Microsoft.Graph.Identity.Governance

$userId = "userId"
$catalogid = Get-MgEntitlementManagementCatalog -Filter "displayName eq 'catalogname'" | Select -ExpandProperty Id
$CatalogOwnerRoleId = "ae79f266-94d4-4dab-b730-feca7e132178" #Constant

$catalogowner = @{
    PrincipalId = "$userId"
    RoleDefinitionId = "$CatalogOwnerRoleId"
    AppScopeId = "/AccessPackageCatalog/$catalogid"
}

New-MgRoleManagementEntitlementManagementRoleAssignment -BodyParameter $catalogowner

回复:

enter image description here

为了确认这一点,我在门户中检查了相同的内容,其中用户成功添加为目录所有者,如下所示:

enter image description here

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