Home > Microsoft > Configure App Profiles or Service Account Profiles > How to Assign the Exchange Administrator Role to an App? > Assign Custom Exchange Online Role Groups to the Application
Export to PDFFollow the steps below to create custom Exchange Online role groups and assign custom Exchange Online role groups to an application:
*Note: For more details on this method, refer to this .
Refer to the instructions in to create custom Exchange Online role groups. For more details on assigning roles to the Exchange Online role group, refer to the .
In Microsoft Graph PowerShell, run the Get-MgServicePrincipal command to store the details of the application.
Connect-MgGraph -Scopes 'Application.Read.All'
$AADApp = Get-MgServicePrincipal -Filter "DisplayName eq ''"
Replace with the application name, Cloud Governance for Exchange.
In the same PowerShell window, connect to Exchange Online PowerShell and run the following commands:
Run the New-ServicePrincipal command to create an Exchange Online service principal object for the application.
Run the Get-ServicePrincipal command to store the details of the service principal in a variable.
New-ServicePrincipal -AppId $AADApp.AppId -ObjectId $AADApp.Id -DisplayName ""
$SP = Get-ServicePrincipal -Identity ""
Replace with the application name, Cloud Governance for Exchange.
In Exchange Online PowerShell, run the following command to add the service principal as a member of the custom role group:
Add-RoleGroupMember -Identity "" -Member $SP.Identity
Replace with the name of your custom Exchange Online role group.