New-MgIdentityGovernanceAccessReviewDefinition_Create1: An error has occurred
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.
- ID: 85cb3eb7-6a19-bb7d-e0fe-f7d793680a36
- Version Independent ID: 4bbaa69b-d41e-6290-acdb-35eb06ffb9d3
- Content: Create definitions - Microsoft Graph beta
- Content Source: api-reference/beta/api/accessreviewset-post-definitions.md
- Product: governance
- Technology: microsoft-graph
- GitHub Login: @jyothig123
- Microsoft Alias: MSGraphDocsVteam