Hi Team,
we are trying to add notificationrule to existing AD role assignments and resource role assignments.
Connect-MgGraph -AccessToken $token
$id = Get-MgPolicyRoleManagementPolicyAssignment -Filter "scopeId eq '/' and scopeType eq 'DirectoryRole' and roleDefinitionId eq '62e90394-69f5-4237-9190-012177145e10'" -ExpandProperty "policy(`$expand=rules)"
$uri = "https://graph.microsoft.com/v1.0/policies/roleManagementPolicies/$($id.PolicyId)/rules/Expiration_EndUser_Assignment"
$method = "PATCH"
$body = '{
"notificationType": "Email",
"recipientType": "Admin",
"notificationLevel": "All",
"isDefaultRecipientsEnabled": "true",
"notificationRecipients": [
"xxxx@ythoutlook.onmicrosoft.com"
]
}'
$response = Invoke-WebRequest -Headers $Header -Uri $uri -Method $method -UseBasicParsing -Body $body
but the API always throwing Invoke-WebRequest : The remote server returned an error: (400) Bad Request.
How to set below notifications using REST API with powershell???
- Send notifications when members are assigned as active to this role: | Role assignment alert
- Send notifications when eligible members activate this role: | Role activation alert
for both AD roles and Azure resource roles??