microsoft-graph-docs icon indicating copy to clipboard operation
microsoft-graph-docs copied to clipboard

New-MgIdentityGovernanceAccessReviewDefinition_Create1: An error has occurred

Open Cardas26 opened this issue 2 years ago • 3 comments

I cannot get this Graph PowerShell commandlet to work. The error in the issue subject line appears with every attempt. Using the -debug parameter did not provide any additional information for troubleshooting. I am using this body and commandlet in PowerShell:

$params = @{ displayName = "PIM review" descriptionForAdmins = "Review for some pim roles" descriptionForReviewers = "Review for some pim roles" scope = @{ "@odata.type" = "#microsoft.graph.accessReviewQueryScope" query = "/roleManagement/directory/roleEligibilityScheduleInstances?$expand=principal&$filter=(isof(principal,'microsoft.graph.user') and roleDefinitionId eq '9c6df0f2-1e7c-4dc3-b195-66dfbd24aa8f')" queryType = "MicrosoftGraph" } settings = @{ mailNotificationsEnabled = $true reminderNotificationsEnabled = $true justificationRequiredOnApproval = $true defaultDecisionEnabled = $false defaultDecision = "Deny" instanceDurationInDays = 25 recommendationsEnabled = $true recurrence = @{ pattern = @{ type = "absoluteMonthly" interval = 3 } range = @{ type = "noEnd" startDate = "2023-06-01" } } } } New-MgIdentityGovernanceAccessReviewDefinition -BodyParameter $params

If I use the https command equivalent in graph explorer, it works:

POST https://graph.microsoft.com/beta/identityGovernance/accessReviews/definitions

Request Body: { "displayName": "PIM review", "descriptionForAdmins": "Review for some pim roles", "descriptionForReviewers": "Review for some pim roles", "scope": { "@odata.type": "#microsoft.graph.accessReviewQueryScope", "query": "/roleManagement/directory/roleEligibilityScheduleInstances?$expand=principal&$filter=(isof(principal,'microsoft.graph.user') and roleDefinitionId eq '9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3')", "queryType": "MicrosoftGraph" }, … "type": "absoluteMonthly", "interval": 3 }, "range": { "type": "noEnd", "startDate": "2023-06-01" } } } }

If there was a typo in $params, I would expect the "Invalid Request" error. But this generic message "An error has occurred" doesn't tell me much.

Can you assist?


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

Cardas26 avatar May 09 '23 08:05 Cardas26