英文:
Set-MailUser Bulk Operations - Issues Updating LegacyExchangeDN
问题
I'm performing a Cross-Tenant O365 migration using the Microsoft way.
Resources:
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/
The issue I have is in the Identity mapping phase where you prep the Mail Users in the target tenant by setting their Primary SMTP, ExchangeGUID, and LegacyExchangeDN. When I perform this operation in bulk, the LegacyExchangeDN fails to change.
I've proven via Exchange Online that I can modify these values with the below cmds:
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″}
The issue I face is specifically related to the LegacyExchangeDN value not getting modified (even though the other values are modified).
Below is the script I made - keep in mind I'm importing a csv with the values I want to set. Also, I'm exporting the get results prior AND after the set 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
}
The csv LegacyExchangeDN value in the csv I import has the following format:
"/o=ExchangeLabs/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=555555555555555555555555555555555555555555555-1c"
I've modified the LegacyExchangeDN values in the imported csv and added the @{Add = "X500: section of the set cmd. I get no errors on the output - the script runs fine - the only issue is that the LegacyExchnageDN value is not getting modified from the set-mailuser cmd.
英文:
I'm performing a Cross-Tenant O365 migration using the Microsoft way.
Resources:
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/
The issue I have is in the Identity mapping phase where you prep the Mail Users in the target tenant by setting their Primary SMTP, ExchangeGUID, and LegacyExchangeDN. When I perform this operation in bulk, the LegacyExchangeDN fails to change.
I've proven via Exchange Online that I can modify these values with the below cmds:
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″}
The issue I face is specifically related to the LegacyExchangeDN value not getting modified (even though the other values are modified).
Below is the script I made - keep in mind I'm importing a csv with the values I want to set. Also, I'm exporting the get results prior AND after the set 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
}
The csv LegacyExchangeDN value in the csv I import has the following format:
"/o=ExchangeLabs/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=555555555555555555555555555555555555555555555-1c"
I've modified the LegacyExchangeDN values in the imported csv and added the @{Add = "X500: section of the set cmd. I get no errors on the output - the script runs fine - the only issue is that the LegacyExchnageDN value is not getting modified from the set-mailuser cmd.
答案1
得分: 1
以下是您提供的代码的翻译部分:
所以事实证明,我的输出没有包括“-EmailAddresses”属性,并且没有反映出设置命令所做的更改。
我还在脚本中连接了x500代理,并创建了两个单独的set-mailuser命令。
以下是最终的脚本:
# 步骤 1:批量获取Get-MailUser并导出到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
}
# 步骤 2:批量设置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"}
}
# 步骤 3:修改后的批量Get-MailUser并导出到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
}
请注意,这是您提供的代码的中文翻译,不包括其他内容。
英文:
So it turns out my output did not include the -EmailAddresses attribute and was not reflecting the changes the set cmd made.
I also concatenated the x500 proxy in the script and created two seperate set-mailuser cmds.
Below is the final script:
# 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
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论