Forum Discussion
_CM_
Aug 15, 2023Copper Contributor
PermissionScopeNotGranted
New-MgRoleManagementDirectoryRoleEligibilityScheduleRequest returns errorCode "PermissionScopeNotGranted","message":"Authorization failed due to missing permission scope" I'm authenticating using an...
- Aug 16, 2023Resolved.
This grants User a new eligible PIM entry for role 'Application Administrator'
Get role id from
Get-MgRoleManagementDirectoryRoleDefinition | select Id, DisplayName | sort DisplayName
this now works
$params = @{
"PrincipalId" = "{user Object ID}"
"RoleDefinitionId" = "9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3" # App Admin role
"Justification" = "Justification text"
"directoryScopeId" = "/{AAD resource ObjectId for e.g. Azure AD app}" # use "/" for Tenant wide
"Action" = "AdminAssign"
"ScheduleInfo" = @{
"StartDateTime" = Get-Date
"Expiration" = @{
"Type" = "AfterDuration"
"Duration" = "PT8H"
}
}
}
New-MgRoleManagementDirectoryRoleEligibilityScheduleRequest -BodyParameter $params
_CM_
Aug 16, 2023Copper Contributor
Resolved.
This grants User a new eligible PIM entry for role 'Application Administrator'
Get role id from
Get-MgRoleManagementDirectoryRoleDefinition | select Id, DisplayName | sort DisplayName
this now works
$params = @{
"PrincipalId" = "{user Object ID}"
"RoleDefinitionId" = "9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3" # App Admin role
"Justification" = "Justification text"
"directoryScopeId" = "/{AAD resource ObjectId for e.g. Azure AD app}" # use "/" for Tenant wide
"Action" = "AdminAssign"
"ScheduleInfo" = @{
"StartDateTime" = Get-Date
"Expiration" = @{
"Type" = "AfterDuration"
"Duration" = "PT8H"
}
}
}
New-MgRoleManagementDirectoryRoleEligibilityScheduleRequest -BodyParameter $params
This grants User a new eligible PIM entry for role 'Application Administrator'
Get role id from
Get-MgRoleManagementDirectoryRoleDefinition | select Id, DisplayName | sort DisplayName
this now works
$params = @{
"PrincipalId" = "{user Object ID}"
"RoleDefinitionId" = "9b895d92-2cd3-44c7-9d02-a6ac2d5ea5c3" # App Admin role
"Justification" = "Justification text"
"directoryScopeId" = "/{AAD resource ObjectId for e.g. Azure AD app}" # use "/" for Tenant wide
"Action" = "AdminAssign"
"ScheduleInfo" = @{
"StartDateTime" = Get-Date
"Expiration" = @{
"Type" = "AfterDuration"
"Duration" = "PT8H"
}
}
}
New-MgRoleManagementDirectoryRoleEligibilityScheduleRequest -BodyParameter $params