Hello @Dapotter, I understand that you want to create Device Management Role Assignment creation where a scope group is specified and getting the error.
To create Intune role assignments with group scope, check the below:
Get the Role definition ID:
Get-MgDeviceManagementRoleDefinition | Select-Object DisplayName, Id
Use the below script to create Intune role assignments with group scope:
Connect-MgGraph -Scopes "DeviceManagementRBAC.ReadWrite.All", "Group.Read.All", "Directory.Read.All"
# Define variables
$roleDefinition = "RoleDefinitionID"
$ResourceScopes = @(
"GroupObjectID"
)
$Members = @(
"UserObjectID"
)
# Placeholder values for display name and description
$DisplayName = "Test Role Assignment"
$Description = "Assigning a role for device management"
# Create role assignment parameters
$CreateParameters = @{
description = $Description
displayName = $DisplayName
resourceScopes = $ResourceScopes
members = $Members
'@odata.type' = '#microsoft.graph.deviceAndAppManagementRoleAssignment'
'******@odata.bind' = "https://graph.microsoft.com/beta/deviceManagement/roleDefinitions('$roleDefinition')"
}
# Create the role assignment
$policy = New-MgDeviceManagementRoleAssignment -BodyParameter $CreateParameters
Created Device Management Role Assignment successfully:
Able to fetch the created Device Management Role Assignments successfully:
Get-MgDeviceManagementRoleAssignment
Reference:
Hope this helps!
If this answer was helpful, please click "Accept the answer" and mark Yes
, as this can help other community members.
If you have any other questions or are still facing issues, feel free to post in the comments and I’ll be happy to assist further.