將 Exchange 2007 信箱轉換為擁有郵件功能的使用者

完成分段移轉後,請將信箱轉換為擁有郵件功能的使用者,讓信箱能夠自動連線到雲端信箱。

為何將信箱轉換為擁有郵件功能的使用者?

如果您已完成 Exchange 分段移轉,將貴組織的 Exchange 2007 內部部署信箱移轉到 Office 365,而且您想要使用 Active Directory 從您的內部部署組織管理雲端式使用者,則應將內部部署信箱轉換為擁有郵件功能的使用者 (MEU)。為什麼?信箱在分段 Exchange 移轉中移轉到雲端後,會發生兩件事:

  • 使用者會各有一個內部部署信箱和雲端信箱。

  • 傳送到使用者內部部署信箱的郵件,會轉寄到他們的雲端信箱。這是因為在移轉程序進行期間,內部部署信箱中的 TargetAddress 屬性會填入雲端信箱的遠端路由位址。這表示使用者需要連線到他們的雲端信箱,才能存取電子郵件。

這個行為會導致兩個問題:

  • 如果有人使用 Microsoft Outlook 開啟信箱,自動探索服務仍會嘗試連線到內部部署信箱,這樣該使用者就無法連線到他們的雲端信箱。如果有使用者尚未移轉到雲端,則在所有使用者完成移轉之前,您不得將自動探索 CNAME 記錄指向雲端。

  • 如果組織在所有內部部署信箱移轉到雲端後解除委任 Exchange,則雲端信箱上與郵件相關的使用者資訊也會一併遺失。Microsoft Online Services 目錄同步作業工具 (DirSync) 會從雲端信箱物件移除資料 (例如 Proxy 位址),因為內部部署信箱已不存在,而 DirSync 無法將它與對應的雲端信箱進行比對。

解決方法是在使用者信箱移轉到雲端後,將內部部署信箱轉換成您內部部署組織中擁有郵件功能的使用者 (MEU)。當您將內部部署信箱轉換成 MEU:

  • 雲端式信箱的 Proxy 位址會複製到新的 MEU;如果您解除委任 Exchange ,則這些 Proxy 位址還是會保留在 Active Directory 中。

  • MEU 的屬性可讓 DirSync 與對應的雲端信箱進行比對。

  • 在使用者建立新的 Outlook 設定檔後,自動探索服務會使用 MEU 將 Outlook 連線至雲端信箱。

建立 MEU 的 PowerShell 指令碼

您可以使用下列指令碼收集雲端式信箱的相關資訊,以及將 Exchange 2007 信箱轉換為 MEU。

下列指令碼會收集您雲端信箱的資訊,並將資訊儲存到一個 CSV 檔案。請先執行這個指令碼。

複製下列指令碼,然後將檔案名稱命名為 ExportO365UserInfo.ps1。

Param($migrationCSVFileName = "migration.csv")
function O365Logon
{
#Check for current open O365 sessions and allow the admin to either use the existing session or create a new one
$session = Get-PSSession | ?{$_.ConfigurationName -eq 'Microsoft.Exchange'}
if($session -ne $null)
{
$a = Read-Host "An open session to Office 365 already exists. Do you want to use this session? Enter y to use the open session, anything else to close and open a fresh session."
if($a.ToLower() -eq 'y')
{
Write-Host "Using existing Office 365 Powershell Session." -ForeGroundColor Green
return
}
$session | Remove-PSSession
}
Write-Host "Please enter your Office 365 credentials" -ForeGroundColor Green
$cred = Get-Credential
$s = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $cred -Authentication Basic -AllowRedirection
$importresults = Import-PSSession -Prefix "Cloud" $s
}
function Main
{
#Verify the migration CSV file exists
if(!(Test-Path $migrationCSVFileName))
{
Write-Host "File $migrationCSVFileName does not exist." -ForegroundColor Red
Exit
}
#Import user list from migration.csv file
$MigrationCSV = Import-Csv $migrationCSVFileName
#Get mailbox list based on email addresses from CSV file
$MailBoxList = $MigrationCSV | %{$_.EmailAddress} | Get-CloudMailbox
$Users = @()
#Get LegacyDN, Tenant, and On-Premise Email addresses for the users
foreach($user in $MailBoxList)
{
$UserInfo = New-Object System.Object
$CloudEmailAddress = $user.EmailAddresses | ?{($_ -match 'onmicrosoft') -and ($_ -cmatch 'smtp:')}
if ($CloudEmailAddress.Count -gt 1)
{
$CloudEmailAddress = $CloudEmailAddress[0].ToString().ToLower().Replace('smtp:', '')
Write-Host "$user returned more than one cloud email address. Using $CloudEmailAddress" -ForegroundColor Yellow
}
else
{
$CloudEmailAddress = $CloudEmailAddress.ToString().ToLower().Replace('smtp:', '')
}
$UserInfo | Add-Member -Type NoteProperty -Name LegacyExchangeDN -Value $user.LegacyExchangeDN
$UserInfo | Add-Member -Type NoteProperty -Name CloudEmailAddress -Value $CloudEmailAddress
$UserInfo | Add-Member -Type NoteProperty -Name OnPremiseEmailAddress -Value $user.PrimarySMTPAddress.ToString()
$UserInfo | Add-Member -Type NoteProperty -Name MailboxGUID -Value $user.ExchangeGUID
$Users += $UserInfo
}
#Check for existing csv file and overwrite if needed
if(Test-Path ".\cloud.csv")
{
$delete = Read-Host "The file cloud.csv already exists in the current directory. Do you want to delete it? Enter y to delete, anything else to exit this script."
if($delete.ToString().ToLower() -eq 'y')
{
Write-Host "Deleting existing cloud.csv file" -ForeGroundColor Red
Remove-Item ".\cloud.csv"
}
else
{
Write-Host "Will NOT delete current cloud.csv file. Exiting script." -ForeGroundColor Green
Exit
}
}
$Users | Export-CSV -Path ".\cloud.csv" -notype
(Get-Content ".\cloud.csv") | %{$_ -replace '"', ''} | Set-Content ".\cloud.csv" -Encoding Unicode
Write-Host "CSV File Successfully Exported to cloud.csv" -ForeGroundColor Green
}
O365Logon
Main

下列指令碼會將內部部署 Exchange 2007 信箱轉換為 MEU。在執行指令碼收集雲端信箱的資訊之後,請執行這個指令碼。

將下列指令碼複製到 .txt 檔案,然後儲存檔案,並將檔案名稱命名為 Exchange2007MBtoMEU.ps1。

param($DomainController = [String]::Empty)
function Main
{
#Script Logic flow
#1. Pull User Info from cloud.csv file in the current directory
#2. Lookup AD Info (DN, mail, proxyAddresses, and legacyExchangeDN) using the SMTP address from the CSV file
#3. Save existing proxyAddresses
#4. Add existing legacyExchangeDN's to proxyAddresses
#5. Delete Mailbox
#6. Mail-Enable the user using the cloud email address as the targetAddress
#7. Disable RUS processing
#8. Add proxyAddresses and mail attribute back to the object
#9. Add msExchMailboxGUID from cloud.csv to the user object (for offboarding support)
if($DomainController -eq [String]::Empty)
{
Write-Host "You must supply a value for the -DomainController switch" -ForegroundColor Red
Exit
}
$CSVInfo = Import-Csv ".\cloud.csv"
foreach($User in $CSVInfo)
{ Write-Host "Processing user" $User.OnPremiseEmailAddress -ForegroundColor Green
Write-Host "Calling LookupADInformationFromSMTPAddress" -ForegroundColor Green
$UserInfo = LookupADInformationFromSMTPAddress($User)
#Check existing proxies for On-Premise and Cloud Legacy DN's as x500 proxies. If not present add them.
$CloudLegacyDNPresent = $false
$LegacyDNPresent = $false
foreach($Proxy in $UserInfo.ProxyAddresses)
{
if(("x500:$UserInfo.CloudLegacyDN") -ieq $Proxy)
{
$CloudLegacyDNPresent = $true
}
if(("x500:$UserInfo.LegacyDN") -ieq $Proxy)
{
$LegacyDNPresent = $true
}
}
if(-not $CloudLegacyDNPresent)
{
$X500Proxy = "x500:" + $UserInfo.CloudLegacyDN
Write-Host "Adding $X500Proxy to EmailAddresses" -ForegroundColor Green
$UserInfo.ProxyAddresses += $X500Proxy
}
if(-not $LegacyDNPresent)
{
$X500Proxy = "x500:" + $UserInfo.LegacyDN
Write-Host "Adding $X500Proxy to EmailAddresses" -ForegroundColor Green
$UserInfo.ProxyAddresses += $X500Proxy
}
#Disable Mailbox
Write-Host "Disabling Mailbox" -ForegroundColor Green
Disable-Mailbox -Identity $UserInfo.OnPremiseEmailAddress -DomainController $DomainController -Confirm:$false
#Mail Enable
Write-Host "Enabling Mailbox" -ForegroundColor Green
Enable-MailUser -Identity $UserInfo.Identity -ExternalEmailAddress $UserInfo.CloudEmailAddress -DomainController $DomainController
#Disable RUS
Write-Host "Disabling RUS" -ForegroundColor Green
Set-MailUser -Identity $UserInfo.Identity -EmailAddressPolicyEnabled $false -DomainController $DomainController
#Add Proxies and Mail
Write-Host "Adding EmailAddresses and WindowsEmailAddress" -ForegroundColor Green
Set-MailUser -Identity $UserInfo.Identity -EmailAddresses $UserInfo.ProxyAddresses -WindowsEmailAddress $UserInfo.Mail -DomainController $DomainController
#Set Mailbox GUID. Need to do this via S.DS as Set-MailUser doesn't expose this property.
$ADPath = "LDAP://" + $DomainController + "/" + $UserInfo.DistinguishedName
$ADUser = New-Object -TypeName System.DirectoryServices.DirectoryEntry -ArgumentList $ADPath
$MailboxGUID = New-Object -TypeName System.Guid -ArgumentList $UserInfo.MailboxGUID
[Void]$ADUser.psbase.invokeset('msExchMailboxGUID',$MailboxGUID.ToByteArray())
Write-Host "Setting Mailbox GUID" $UserInfo.MailboxGUID -ForegroundColor Green
$ADUser.psbase.CommitChanges()
Write-Host "Migration Complete for" $UserInfo.OnPremiseEmailAddress -ForegroundColor Green
Write-Host ""
Write-Host ""
}
}
function LookupADInformationFromSMTPAddress($CSV)
{
$Mailbox = Get-Mailbox $CSV.OnPremiseEmailAddress -ErrorAction SilentlyContinue
if($Mailbox -eq $null)
{
Write-Host "Get-Mailbox failed for" $CSV.OnPremiseEmailAddress -ForegroundColor Red
continue
}
$UserInfo = New-Object System.Object
$UserInfo | Add-Member -Type NoteProperty -Name OnPremiseEmailAddress -Value $CSV.OnPremiseEmailAddress
$UserInfo | Add-Member -Type NoteProperty -Name CloudEmailAddress -Value $CSV.CloudEmailAddress
$UserInfo | Add-Member -Type NoteProperty -Name CloudLegacyDN -Value $CSV.LegacyExchangeDN
$UserInfo | Add-Member -Type NoteProperty -Name LegacyDN -Value $Mailbox.LegacyExchangeDN
$ProxyAddresses = @()
foreach($Address in $Mailbox.EmailAddresses)
{
$ProxyAddresses += $Address
}
$UserInfo | Add-Member -Type NoteProperty -Name ProxyAddresses -Value $ProxyAddresses
$UserInfo | Add-Member -Type NoteProperty -Name Mail -Value $Mailbox.WindowsEmailAddress
$UserInfo | Add-Member -Type NoteProperty -Name MailboxGUID -Value $CSV.MailboxGUID
$UserInfo | Add-Member -Type NoteProperty -Name Identity -Value $Mailbox.Identity
$UserInfo | Add-Member -Type NoteProperty -Name DistinguishedName -Value (Get-User $Mailbox.Identity).DistinguishedName
$UserInfo
}
Main

將內部部署信箱轉換為 MEU 的設定步驟

按照下列步驟完成程序。

  1. 複製 ExportO365UserInfo.ps1、Exchange2007MBtoMEU.ps1 以及用來在您內部部署伺服器的相同目錄中執行移轉批次的 CSV 檔案。

  2. 將移轉用的 CSV 檔案重新命名為 migration.csv。

  3. . 在 Exchange 管理命令介面中,執行下列命令。指令碼會假設 CSV 檔位於同樣的目錄中,且命名為 migration.csv。

    .\ExportO365UserInfo.ps1

    系統會提示您使用現有的工作階段,或開啟新的工作階段。

  4. 請輸入 n,然後按 Enter 以開啟新的工作階段。

    指令碼隨即執行,然後會將 Cloud.csv 檔儲存到目前執行的目錄。

  5. 輸入您雲端組織的系統管理認證,然後按一下 [確定]。

  6. 在新 Exchange 管理命令介面工作階段中執行下列命令。這個命令會假設 ExportO365UserInfo.ps1 與 Cloud.csv 都位於同一個目錄中。

    .\Exchange2007MBtoMEU.ps1 <FQDN of on-premises domain controller>

    例如:

    .\Exchange2007MBtoMEU.ps1 DC1.contoso.com

    指令碼會針對 Cloud.csv 中包含的所有使用者內部部署信箱傳換為 MEU。

  7. 確認已建立新的 MEU。在 Active Directory 使用者和電腦中,執行下列操作:

    1. 按一下 [動作] > [尋找]

    2. 按一下 [Exchange] 索引標籤

    3. 選取 [僅顯示 Exchange 收件者],然後選取 [擁有外部電子郵件地址的使用者]。

    4. 按一下 [立即尋找]。

    [搜尋結果] 底下會列出已轉換為 MEU 的信箱。

  8. 使用 Active Directory 使用者和電腦、ADSI 編輯器或 Ldp.exe,驗證已使用正確的資訊填入下列 MEU 屬性。

    • legacyExchangeDN

    • mail

    • msExchMailboxGuid

    • proxyAddresses

    • targetAddress

擴展您的技能
探索訓練
優先取得新功能
加入 Office 測試人員

這項資訊有幫助嗎?

感謝您的意見反應!

感謝您的意見反應! 我們將協助您與其中一位 Office 支援專員連絡以深入了解您的意見。

×