I figured out role assignment in a past post, but eligibility is still giving me a little difficulty.
I use the following to assign the built in Auth admin role to a group, and scope it to an Admin Unit.
$params = @{
Action = "adminAssign"
Justification = "Assign Auth Admin eligibility to group"
RoleDefinitionId = "c4e39bd9-1100-46d3-8c65-fb160da0071f" #Auth admin role ID
DirectoryScopeId = '/administrativeUnits/{0}' -f $AdminUnit
PrincipalId = $Id
ScheduleInfo = @{
StartDateTime = Get-Date
Expiration = @{
Type = "noExpiration"
}
}
}
New-MgRoleManagementDirectoryRoleEligibilityScheduleRequest -BodyParameter $params
However despite adapting my prior code I keep getting the following error.
New-MgRoleManagementDirectoryRoleEligibilityScheduleRequest : The subject is not found.
Status: 404 (NotFound)
ErrorCode: SubjectNotFound
I'm not sure exactly what is not found, nor why it's not finding it. Can I request some guidance here?
My prior code was successful:
$params = @{
"@odata.type" = "#microsoft.graph.unifiedRoleAssignment"
#Auth Admin
roleDefinitionId = "c4e39bd9-1100-46d3-8c65-fb160da0071f"
principalId = $Id
directoryScopeId = '/administrativeUnits/"{0}"' -f $AdminUnit
}
New-MgRoleManagementDirectoryRoleAssignment -BodyParameter $params```
$AdminUnitcontain? If it contains a response fromGet-MgDirectoryAdministrativeUnitthen you probably want to use just the id, eg:'/administrativeUnits/{0}' -f $AdminUnit.Id$AdminUnit = Get-MgDirectoryAdministrativeUnit -Filter "DisplayName eq '$AuName'" | Select -Expand IdDirectoryScopeId = '/administrativeUnits/{0}' -f $AdminUnit.Id$AdminUnitand$Idare GUIDs instead of an object having anIdproperty. The rest, the Body for the request looks fine so that could be the only issue.[datetime]::UtcNowinstead ofGet-Date. And if that fails, test withInvoke-MgGraphRequest POST 'v1.0/roleManagement/directory/roleEligibilityScheduleRequests' -Body $params, the API might give a better error response that can help us determine what is wrong