The New-MgRoleManagementDirectoryRoleDefinition cmdlet is used to create a new custom role definition in Microsoft Entra ID (formerly Azure AD). Role definitions specify a collection of permissions and actions that admins can assign to users, groups, or service principals through role assignments. This cmdlet is useful when the built-in directory roles such as Global Administrator or User Administrator do not meet the organization’s exact needs. By creating custom roles, IT teams can follow the principle of least privilege, only granting users the permissions necessary for their job functions.
This article shows you how to create a directory role definition using both Microsoft Entra admin center and Microsoft Graph PowerShell:
Admins can create and assign custom directory roles via the portal's Roles and administrators section
Install Graph module with role management permissions:
Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "RoleManagement.ReadWrite.Directory"
Run the script below by specifying role details and permission actions:
New-MgRoleManagementDirectoryRoleDefinition -DisplayName <name> -Description <desc> -Permissions <permissions-array>
New-MgRoleManagementDirectoryRoleDefinition -DisplayName "ReadOnly Role" -Description "Read only access" -Permissions @(@{AllowedResourceActions=@("microsoft.directory/*/read")})
New-MgRoleManagementDirectoryRoleDefinition -DisplayName "Password Reset Role" -Description "Allow password resets" -Permissions @(@{AllowedResourceActions=@("microsoft.directory/users/password/reset")})
New-MgRoleManagementDirectoryRoleDefinition -DisplayName "Custom Admin" -Description "Admin with read & write" -Permissions @(@{AllowedResourceActions=@("microsoft.directory/*/read", "microsoft.directory/users/*/write")})
The following essential parameters can be used along with the New-MgRoleManagementDirectoryRoleDefinition cmdlet:
| Parameter | Description |
|---|---|
| -DisplayName | Name for the custom role (required). |
| -Description | Descriptive summary of the custom role. |
| -Permissions | Array of allowed resource actions or permissions (required). |
| -IsBuiltIn | Indicates if the role is a built-in definition. |
| -TemplateId | Template reference for role creation. |
ADManager Plus, an identity governance and administration solution with comprehensive Microsoft Entra ID management and reporting capabilities, simplifies complex admin tasks from a single, user-friendly console: