When managing access and roles in Microsoft 365 and Azure Active Directory (AAD), there are times you’ll need to activate a directory role before assigning it to users. That’s exactly what the New-MgDirectoryRole cmdlet is designed to do.
In this article, we'll explain what this cmdlet is, why it matters, how to use it, and share a few practical examples to help you get started.
New-MgDirectoryRole is a Microsoft Graph PowerShell cmdlet that allows administrators to activate a directory role in Azure Active Directory based on a predefined directory role template.
Each role (e.g., Exchange Administrator, Conditional Access Administrator) has a corresponding template, and roles cannot be assigned until they are first activated using this cmdlet.
Once activated, these roles become visible in your tenant and can be assigned to users via the Microsoft 365 admin center or programmatically through PowerShell.
There are several key reasons why you might use this cmdlet:
New-MgDirectoryRole -BodyParameter <hashtable>
Required Parameter:
Import-Module Microsoft.Graph.Identity.DirectoryManagement
$params = @{
roleTemplateId = "fe930be7-5e62-47db-91af-98c3a49a38b1"
}
New-MgDirectoryRole -BodyParameter $params
This activates the Global Reader role in your tenant using its template ID.
Tip: You can use Get-MgDirectoryRoleTemplate to list all available role templates and their IDs.
No. A directory role template can only be activated once. Trying to activate it again will result in an error.
Use the following command:
Get-MgDirectoryRoleTemplate | Select-Object DisplayName, Id
Yes, you need appropriate directory-level permissions such as RoleManagement.ReadWrite.Directory.
Here are some real-world scenarios where New-MgDirectoryRole is useful:
The New-MgDirectoryRole cmdlet is essential for any admin who wants to activate and assign roles in Azure AD securely and programmatically. By leveraging this cmdlet in your automation scripts or governance workflows, you ensure that your role management is consistent, secure, and scalable.
Want to go further? Combine this with New-MgDirectoryRoleMemberByRef to assign the activated roles to users seamlessly!
Did You Know? Managing Microsoft 365 applications is even easier with automation. Try our Graph PowerShell scripts to automate tasks like generating reports, cleaning up inactive Teams, or assigning licenses efficiently.
Ready to get the most out of Microsoft 365 tools? Explore our free Microsoft 365 administration tools to simplify your administrative tasks and boost productivity.
© Your Site Name. All Rights Reserved. Design by HTML Codex