Skip to main content

Import-MailboxMappings

Import mailbox and recipient mappings with PowerShell

Updated over a month ago

Command

Import-MailboxMappings

Description

The command to import mailbox mappings from a file.

CSV mailbox mappings file

You can generate a mappings file with ShareGate or create one yourself.

To export mappings with ShareGate Migrate, see Export-MailboxMappings.

Note: When you export your mailbox and recipient mappings directly in the app, they are separated. To combine the mappings you exported from the app for PowerShell, see Combine your mailbox and recipient mappings for PowerShell.

You don't have to combine your mappings if you export your mailbox mappings with the PowerShell cmdlet.

If you want to create your own mapping file, you can export mailbox mappings with ShareGate Migrate to create a template and follow its formatting.

You can also create it manually as long as you follow the structure below and save it as a comma-delimited CSV.

Source user id

Source user name

Source user email

Destination user id

Destination user name

Destination user email

dd1558d5-66d1-4ca8-b1a7-ce1df75df9eb

Your User

916faa7c-4a37-42f3-9926-ddfda95522f3

Yourdestination User

Examples

Import mailbox mappings from a file

# Define the file path for the CSV file containing mailbox mappings
$filePath = "C:\MailboxMappingsToImport.csv"

# Connect to the source Microsoft Online tenant
$sourceConnection = Connect-MicrosoftOnline

# Connect to the destination Microsoft Online tenant
$destinationConnection = Connect-MicrosoftOnline

# Import mailbox mappings from the specified CSV file
Import-MailboxMappings -SourceConnection $sourceConnection -DestinationConnection $destinationConnection -Path $filePath

Import mailbox mappings from the export mappings command result

# Define the file path for the CSV file to store mailbox mappings
$filePath = "C:\MailboxMappingsToImport.csv"

# Connect to the source Microsoft Online tenant
$sourceConnection = Connect-MicrosoftOnline

# Connect to the destination Microsoft Online tenant
$destinationConnection = Connect-MicrosoftOnline

# Export all mailbox mappings from the source tenant to the destination tenant
# The exported file can be reused for future import commands
Export-MailboxMappings -SourceConnection $sourceConnection -DestinationConnection $destinationConnection -Path $filePath

# Import mailbox mappings using the previously exported CSV file
Import-MailboxMappings -SourceConnection $sourceConnection -DestinationConnection $destinationConnection -Path $filePath

Syntax

Import-MailboxMappings
-SourceConnection <Connection>
-DestinationConnection <Connection>
-Path <FileInfo>

Parameters

-DestinationConnection <Connection>

Specifies the destination connection.

Required?

True

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-Path <FileInfo>

Specifies the .csv file path to map the source mailboxes.

Required?

True

Default value

None

Accept pipeline input?

True (ByValue)

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

-SourceConnection <Connection>

Specifies the source connection.

Required?

True

Default value

None

Accept pipeline input?

False

Accept wildcard characters?

False

Parameter set name

(All)

Aliases

None

Did this answer your question?