我正在使用 Microsoft 方式执行跨租户 O365 迁移。 资源: https://learn.microsoft.com/en-us/microsoft-365/enterprise/cross-tenant-mailbox-migration?view=o365-worldwide https://blog.matrixpost.net/office-cross-tenant-mailbox-migration/
我遇到的问题是在身份映射阶段,您通过设置主要 SMTP、ExchangeGUID 和 LegacyExchangeDN 来准备目标租户中的邮件用户。当我批量执行此操作时,LegacyExchangeDN 无法更改。
我已经通过 Exchange Online 证明我可以使用以下命令修改这些值:
set-mailuser -identity "CT Migration" -ExchangeGuid 55555555-5555-5555-5555-555555555555
Set-MailUser -Identity “CT Migration” -EmailAddresses @{add=”X500:/o=ExchangeLabs/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=55555555555555555555555555555555555555555-0″}
我面临的问题与 LegacyExchangeDN 值未得到修改特别相关(即使其他值已修改)。
下面是我制作的脚本 - 请记住,我正在导入带有我想要设置的值的 csv。另外,我在设置 cmd 之前和之后导出获取结果:
# Step 1: Bulk Get-MailUser and export to CSV
$csvFile = "C:\Scripts\SetMailUserBulk.csv"
$outputFile = "C:\Scripts\PriorToSet.csv"
$users = Import-Csv $csvFile
$attributes = "Name", "LegacyExchangeDN", "ExchangeGUID", "UserPrincipalName", "PrimarySMTPAddress", "ExternalEmailAddress"
$users | ForEach-Object {
$user = $_
$mailUser = Get-MailUser -Identity $user.Identity | Select-Object $attributes
$mailUser | Select-Object $attributes | Export-Csv -Append -Path $outputFile -NoTypeInformation
}
# Step 2: Bulk Set-MailUser
$updatedUsers = Import-Csv $csvFile
$updatedUsers | ForEach-Object {
$user = $_
$mailUser = Get-MailUser -Identity $user.Identity
Set-MailUser -Identity $user.Identity `
-ExchangeGuid $user.ExchangeGuid `
-EmailAddresses @{Add = "X500:$($user.LegacyExchangeDN)"}
}
# Step 3: Bulk Get-MailUser after modification and export to CSV
$modifiedOutputFile = "C:\Scripts\AfterSet.csv"
$updatedUsers | ForEach-Object {
$user = $_
$mailUser = Get-MailUser -Identity $user.Identity
$mailUser | Select-Object $attributes | Export-Csv -Append -Path $modifiedOutputFile -NoTypeInformation
}
我导入的 csv 中的 csv LegacyExchangeDN 值具有以下格式:
"/o=ExchangeLabs/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=555555555555555555555555555555555555555555555-1c"
我修改了导入的 csv 中的 LegacyExchangeDN 值,并添加了 @{Add = "X500: set cmd 的部分。我在输出中没有收到任何错误 - 脚本运行良好 - 唯一的问题是 LegacyExchnageDN 值是未从 set-mailuser cmd 进行修改。
所以事实证明我的输出不包含 -EmailAddresses 属性,并且没有反映 set cmd 所做的更改。
我还在脚本中连接了 x500 代理并创建了两个单独的 set-mailuser cmd。 以下是最终脚本:
# Step 1: Bulk Get-MailUser and export to CSV
$csvFile = "C:\Scripts\SetMailUserBulk.csv"
$outputFile = "C:\Scripts\PriorToSet.csv"
$users = Import-Csv $csvFile
$attributes = "Name", "EmailAddresses", "LegacyExchangeDN", "ExchangeGUID", "UserPrincipalName", "PrimarySMTPAddress", "ExternalEmailAddress"
$users | ForEach-Object {
$user = $_
$mailUser = Get-MailUser -Identity $user.Identity | Select-Object $attributes
$mailUser | Select-Object $attributes | Export-Csv -Append -Path $outputFile -NoTypeInformation
}
# Step 2: Bulk Set-MailUser
$updatedUsers = Import-Csv $csvFile
$updatedUsers | ForEach-Object {
$user = $_
$mailUser = Get-MailUser -Identity $user.Identity
$Email = "X500:" + "$($user.LegacyExchangeDN)"
write-host "$Email"
Set-MailUser -Identity $user.Identity -ExchangeGuid $user.ExchangeGuid -PrimarySmtpAddress $user.PrimarySMTPAddress
Set-MailUser -Identity $user.Identity ` -EmailAddresses @{Add = "$Email"}
}
# Step 3: Bulk Get-MailUser after modification and export to CSV
$modifiedOutputFile = "C:\Scripts\AfterSet.csv"
$updatedUsers | ForEach-Object {
$user = $_
$mailUser = Get-MailUser -Identity $user.Identity
$mailUser | Select-Object $attributes | Export-Csv -Append -Path $modifiedOutputFile -NoTypeInformation
}
Mailuser 不适合我。对于所有在线交换的用户来说,这并不一致。
仅适用于作为实际邮件用户创建的帐户。