Simplify user tasks like bulk creation, updates, password resets, deletions, license checks & more — all from one place.
🚀 Launch ToolkitAzure AD allows administrators to define custom directory roles that fit unique organizational requirements. The New-MgRoleManagementDirectoryRoleDefinition cmdlet enables you to create these roles using Microsoft Graph PowerShell — assigning only the required permissions and limiting unnecessary access.
This cmdlet is essential when adhering to least-privilege principles while still granting functionality to specific teams or tools.
New-MgRoleManagementDirectoryRoleDefinition -BodyParameter <hashtable>
Import-Module Microsoft.Graph.Identity.Governance
$params = @{
description = "Update basic properties of application registrations"
displayName = "Application Registration Support Administrator"
rolePermissions = @(
@{
allowedResourceActions = @(
"microsoft.directory/applications/basic/read"
)
}
)
isEnabled = $true
}
New-MgRoleManagementDirectoryRoleDefinition -BodyParameter $params
This role allows limited read-only access to basic app registration data.
$params = @{
description = "Custom role to allow group membership management"
displayName = "Group Membership Manager"
rolePermissions = @(
@{
allowedResourceActions = @(
"microsoft.directory/groups/basic/read",
"microsoft.directory/groups/members/update"
)
}
)
isEnabled = $true
}
New-MgRoleManagementDirectoryRoleDefinition -BodyParameter $params
This role allows users to read group info and update group members (but not owners or group settings).
This script is highly useful for the following real-world scenarios:
| Error Message | Cause | Solution |
| Access Denied | Insufficient privileges or missing API permissions | Use Graph scopes: RoleManagement.ReadWrite.Directory |
| InvalidRequest: allowedResourceActions is null or empty | Missing permissions block in role definition | Ensure allowedResourceActions has at least one valid action |
| ResourceNotFound | Misspelled or unsupported action name | Use official permission list |
| Request_BadRequest: Role definition already exists | Duplicate display name | Use a unique displayName for each role |
The New-MgRoleManagementDirectoryRoleDefinition cmdlet empowers administrators to create custom directory roles tailored to organizational needs. By specifying precise resource actions, it supports granular access control and promotes least privilege in Microsoft 365 environments.
This cmdlet works seamlessly with:
Custom roles are a powerful feature, especially for delegation, automation, and compliance-driven RBAC models. If your admin model demands flexibility without compromising security — this cmdlet is a must-have in your toolkit.
© m365corner.com. All Rights Reserved. Design by HTML Codex