Microsoft 365 Exchange Online Management








Permission
Purpose
Create and Authorize Service Account

Locate Organization ID


Last updated
Was this helpful?
Was this helpful?
PowerShell 7.4.5
# Connect to "AzureAD"
PS /home/wbagg> <b>Connect-AzureAD</b>
VERBOSE: Authenticating to Azure ...
VERBOSE: Building your Azure drive ...
Loading personal and system profiles took 8788ms.
# Run the following to get the object-id of our application, replacing
# application-id with the actual Application (Client) ID of our new app
#
# PS /home/wbagg> <b>Get-AzADServicePrincipal -AppID "<application-id>" | Select-Object DisplayName, AppId, Id | Format-List
#
# For example:
PS /home/wbagg> <b>Get-AzADServicePrincipal -AppID aaaaaaaa-1111-2222-3333-444444444444 | Select-Object DisplayName, AppId, Id | Format-List
DisplayName : Dropzone AI
AppId : aaaaaaaa-1111-2222-3333-444444444444
Id : 44726f70-7a6f-6e65-5761-734865726521
# Connect to ExchangeOnline
PS /home/wbagg> Connect-ExchangeOnline
# Run the following to create the service principal, replacing
# application-id and object-spid from the earlier values
#
# PS /home/wbagg> New-ServicePrincipal -AppId "<application-id>" -ObjectId "<object-spid>" -DisplayName "Dropzone AI"
#
# for example
PS /home/wbagg> New-ServicePrincipal -AppId "aaaaaaaa-1111-2222-3333-444444444444" -ObjectId "44726f70-7a6f-6e65-5761-734865726521" -DisplayName "Dropzone AI"
DisplayName ObjectId AppId
----------- -------- -----
Dropzone AI 44726f70-7a6f-6e65-5761-734865726521 aaaaaaaa-1111-2222-3333-444444444444# Run the following to enable the Transport Hygiene role, replacing the
# application-id with the actual Application (Client) ID of our new app
#
# PS /> New-ManagementRoleAssignment -App "application-id" -Role "Transport Hygiene"
#
PS /> New-ManagementRoleAssignment -App "aaaaaaaa-1111-2222-3333-444444444444" -Role "Transport Hygiene"
Name Role RoleAssigneeName RoleAssigneeType AssignmentMethod EffectiveUserName
---- ---- ---------------- ---------------- ---------------- -----------------
Transport Hygiene-44726f70... Transport Hygiene ba0efd83-6465-48a... ServicePrincipal Direct