How to: Add Mailbox Import Export Role in Office 365 using PowerShell

When you are in Exchange Online environment, you might have required (or asked) to assign “Mailbox Import Export Role” for some kind of mailbox operation, like importing PST files, delete messages from mailbox using Search-Mailbox cmdlet, restore deleted mails using Restore-RecoverableItems cmdlet, etc. When you import PST files without this role you will probably receive this error message: “Please add Mailbox Import Export role for use running import and check back in 60 minutes“.

By default, the “Mailbox Import Export” role is not assigned to any role group, even to the Organization Management role group. Typically, you assign a role to a built-in/custom role group, or you can assign a role to a user, or a universal security group. In this post, I am going to share PowerShell script to find who has access to Mailbox Import Export role and how to assign this role to user, security group and existing build-in/custom role group.

Before proceed, run the following commands to load Exchange Online powershel module:

$o365Cred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $o365Cred -Authentication Basic -AllowRedirection
Import-PSSession $Session

Summary

Assign Mailbox Import Export role to user, security group and existing role group

Run the following command to assign the role for the individual user account.

New-ManagementRoleAssignment –Role "Mailbox Import Export" –User "user name"

Run the following command to set this role for the universal security group.

New-ManagementRoleAssignment –Role "Mailbox Import Export" –SecurityGroup "group name"

Use the below command to add this role to existing management role group.

New-ManagementRoleAssignment -Role "Mailbox Import Export" -SecurityGroup "Organization Management" -Name "Import Export Org Management"

Note: You have to create a new Exchange Online PowerShell session to get new role permissions.

Find who has access to Mailbox Import Export role

You can run the following command to find out who has the role already.

Get-ManagementRoleAssignment –Role "Mailbox Import Export" | FL RoleAssigneeName, Name

In the result, you may see the Organization Management role group even though you haven’t explicitly given the rights , this is because of the members of the Organization Management role group can delegate the “Mailbox Import Export” role to themselves and other groups or users.

Remove Management Role Assignment

If you want to remove the existing role assignment, first you have to find the name of the role assignment that you want to delete using the command Get-ManagementRoleAssignment and run the following powershell command to clear the existing role.

Remove-ManagementRoleAssignment "Import Export Org Management" -Confirm:$false
Advertisement

1 thought on “How to: Add Mailbox Import Export Role in Office 365 using PowerShell”

Leave a Comment