Skip to content

New command: m365 exo approleassignment add #5988

@MartinM85

Description

@MartinM85

Usage

m365 exo approleassignment add [options]

Description

Grants permissions to an application that's accessing data in Exchange Online and specify which mailboxes an app can access.

Options

Option Description
--roleDefinitionId [roleDefinitionId] Id of a role to be assigned. Specify either roleDefinitionId or roleDefinitionName, but not both.
--roleDefinitionName [roleDefinitionName] Name of a role to be assigned. Specify either roleDefinitionId or roleDefinitionName, but not both.
--principalId [principalId] Id of a service principal to which the assignment is granted. Specify either principalId or principalName, but not both.
--principalName [principalName] Name of a service principal to which the assignment is granted. Specify either principalId or principalName, but not both.
--scopeUserId [scopeUserId] Id of a user to which the assignment is scoped. Specify either scopeTenant, scopeUserId, scopeUserName, scopeGroupId, scopeGroupName, scopeAdministrativeUnitId, scopeAdministrativeUnitName, scopeCustomAppId, or scopeCustomAppName, but not multiple.
--scopeUserName [scopeUserName] UPN of a user to which the assignment is scoped. Specify either scopeTenant, scopeUserId, scopeUserName, scopeGroupId, scopeGroupName, scopeAdministrativeUnitId, scopeAdministrativeUnitName, scopeCustomAppId, or scopeCustomAppName, but not multiple.
--scopeGroupId [scopeGroupId] Id of a group to which the assignment is scoped. Specify either scopeTenant, scopeUserId, scopeUserName, scopeGroupId, scopeGroupName, scopeAdministrativeUnitId, scopeAdministrativeUnitName, scopeCustomAppId, or scopeCustomAppName, but not multiple.
--scopeGroupName [scopeGroupName] Name of a group to which the assignment is scoped. Specify either scopeTenant, scopeUserId, scopeUserName, scopeGroupId, scopeGroupName, scopeAdministrativeUnitId, scopeAdministrativeUnitName, scopeCustomAppId, or scopeCustomAppName, but not multiple.
--scopeAdministrativeUnitId [scopeAdministrativeUnitId] Id of an administrative unit to which the assignment is scoped. Specify either scopeTenant, scopeUserId, scopeUserName, scopeGroupId, scopeGroupName, scopeAdministrativeUnitId, scopeAdministrativeUnitName, scopeCustomAppId, or scopeCustomAppName, but not multiple.
--scopeAdministrativeUnitName [scopeAdministrativeUnitName] Name of an administrative unit to which the assignment is scoped. Specify either scopeTenant, scopeUserId, scopeUserName, scopeGroupId, scopeGroupName, scopeAdministrativeUnitId, scopeAdministrativeUnitName, scopeCustomAppId, or scopeCustomAppName, but not multiple.
--scopeCustomAppId [scopeCustomAppId] Id of a custom application scope to which the assignment is scoped. Specify either scopeTenant, scopeUserId, scopeUserName, scopeGroupId, scopeGroupName, scopeAdministrativeUnitId, scopeAdministrativeUnitName, scopeCustomAppId, or scopeCustomAppName, but not multiple.
--scopeCustomAppName [scopeCustomAppName] Name of a custom application scope to which the assignment is scoped. Specify either scopeTenant, scopeUserId, scopeUserName, scopeGroupId, scopeGroupName, scopeAdministrativeUnitId, scopeAdministrativeUnitName, scopeCustomAppId, or scopeCustomAppName, but not multiple.
--scopeTenant Specify whether the tenant-wide scope is applied. Specify either scopeTenant, scopeUserId, scopeUserName, scopeGroupId, scopeGroupName, scopeAdministrativeUnitId, scopeAdministrativeUnitName, scopeCustomAppId, or scopeCustomAppName, but not multiple.

Alternate options

Option Description
-s, --scope <scope> Scope of the roleassignment. Allowed values are: tenant, administrativeUnit, group, user, custom.
--userId [userId] Id of a user to which the assignment is scoped. Specify either userId or userName when scope is set to user.
--userName [userName] UPN of a user to which the assignment is scoped. Specify either userId or userName when scope is set to user.
--groupId [groupId] Id of a group to which the assignment is scoped. Specify either groupId or groupName when scope is set to group.
--groupName [groupName] Name of a group to which the assignment is scoped. Specify either groupId or groupName when scope is set to group.
--administrativeUnitId [administrativeUnitId] Id of an administrative unit to which the assignment is scoped. Specify either administrativeUnitId or administrativeUnitName when scope is set to administrativeUnit.
--administrativeUnitName [administrativeUnitName] Name of an administrative unit to which the assignment is scoped. Specify either administrativeUnitId or administrativeUnitName when scope is set to administrativeUnit.
--customAppScopeId [customAppScopeId] Id of a custom application scope to which the assignment is scoped. Specify either customAppScopeId or customAppScopeName when scope is set to custom.
--customAppScopeName [customAppScopeName] Name of a custom application scope to which the assignment is scoped. Specify either customAppScopeId or customAppScopeName when scope is set to custom.

Examples

Assign a role specified by id to a service principal specified by id and scope the assignment to the whole tenant

m365 exo approleassignment add --roleDefinitionId 777b752-f9b7-4205-a2b1-5db0d6a0ccfc --principalId 7a2ca997-9461-402e-9882-58088a370889 --scopeTenant

Assign a role specified by id to a service principal specified by id and scope the assignment to a user specified by id

m365 exo approleassignment add --roleDefinitionId 777b752-f9b7-4205-a2b1-5db0d6a0ccfc --principalId 7a2ca997-9461-402e-9882-58088a370889 --scopeUserId a4738dd8-fc0f-4646-87fb-47539f5c651b

Assign a role specified by name to a service principal specified by name and scope the assignment to a group specified by name

m365 exo approleassignment add --roleDefinitionName 'Application Contacts.ReadWrite' --principalName 'ContactsSyncApp' --scopeGroupName 'Marketing'

Assign a role specified by name to a service principal specified by id and scope the assignment to an administrative unit specified by name

m365 exo approleassignment add --roleDefinitionName 'Application Calendars.Read' --principalId fa631c4d-ac9f-4884-a7f5-13c659d177e3 --scopeAdministrativeUnitName 'Equipment - EMEA'

Default properties

No response

Additional Info

Exchange Online RBAC is alternate to application permissions for accessing mailboxes, but without a need to allow application access policy for specific mailboxes via Exchange Online PowerShell.

It simplifies the whole process and admin can avoid to use Exchange Online PowerShell to configure application access policy.

https://learn.microsoft.com/graph/api/rbacapplication-post-roleassignments?view=graph-rest-beta&tabs=http#example-5-create-a-role-assignment-for-exchange-online-provider-with-administrative-unit-scope

https://learn.microsoft.com/graph/api/resources/customappscope?view=graph-rest-beta

https://learn.microsoft.com/exchange/permissions-exo/application-rbac#supported-application-roles

I will work on this

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions