azurepowershellmicrosoft-graph-apiidentity-managementazure-identity

How can I add an Owner to an Azure Entitlement Management Catalog in powershell or using Graph API?


Im trying to add a Catalog Owner to my Catalog in Azure Identity Management. This doesn't seem to be documented anywhere. I've tried different request bodies using both the PS Graph Module and the graph API directly (PATCH /identityGovernance/entitlementManagement/catalogs/{id}), but the patch call always returns a 204 no matter the properties.

E.g.:

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

Is there any way to do this? Or is manually in the portal the only option?


Solution

  • I have one catalog named DemoCatalog with no Catalog Owners assigned as below:

    enter image description here

    To add an Owner to an Azure Entitlement Management Catalog using MS Graph PowerShell, you can make use of below script:

    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
    

    Response:

    enter image description here

    To confirm that, I checked the same in Portal where user added as Catalog Owner successfully as below:

    enter image description here