As most of Hosted Messaging and Collaboration (HMC) companies start planning to migrate to Exchange 2010 SP2 hosted environment due to the change in strategy that was announced about the future of /hosting mode here, so most HMC customer have to move directly to Exchange 2010 SP2 in hosted mode as discussed here, and one of the activities come up to migrate from HMC to Exchange 2010 SP2 is Downsizing activity in the running HMC environment to utilize part of hardware to be reused in the new Exchange 2010 SP2 environment, and although it looks like a simple activity for some IT people but there are a lot of challenges that can be in some cases for some specific HMC components show stopper to continue the down activity, one of the important resource while working in this activity is Microsoft Provisioning System SDK that can be downloaded from here.
In this post series I will share all my experience with HMC downsizing activity and explain how I deal with different challenges in this activity, in Part1 I covered the first step of HMC downsizing activity to select server roles that will be decommissioned, then covered most of preparations tasks in each of the selected roles.
In this post I will cover the preparations specific for Mailbox Role which is the most critical role of downsizing activity, and different preparations steps for Exchange MBX role can be divided as follows:
Mail Server Mailstore Organizations before Mailbox Move After Mailbox Move MBX01 MBX01-DB01 Org1.com Org2.com Org3.Net … … MBX01-DB02 … … MBX02 MBX02-DB01 … … MBX02-DB02 … … … … … …
Mail Server
Mailstore
Organizations before Mailbox Move
After Mailbox Move
MBX01
MBX01-DB01
Org1.com Org2.com Org3.Net …
…
MBX01-DB02
MBX02
MBX02-DB01
MBX02-DB02
PrimarySMTPAddress,TargetDB Maged@Org1.net,MBXV01\MBXV01SG01\MBXV01SG01DB01 Kip@Org2.com,MBXV01\MBXV01SG01\MBXV01SG01DB01 And the used script is below:
PrimarySMTPAddress,TargetDB Maged@Org1.net,MBXV01\MBXV01SG01\MBXV01SG01DB01 Kip@Org2.com,MBXV01\MBXV01SG01\MBXV01SG01DB01
And the used script is below:
# 1. Use the Exchange Management Shell to get the source server name with Get-ExchangeServer | Select Name # 2. Use the Exchange Management Shell to populate the input CSV file with Get-MailboxDatabase | where {$_.ServerName.Contains("sourceservername") -eq "true"} | Get-Mailbox | Select PrimarySMTPAddress,Database | Export-Csv C:\Temp\MbxsToBeMoved.csv –NoTypeInformation # 3. Change ‘Database’ field header to ‘TargetDB’ # 4. Modify database/targetdb field entries as required in the CSV # 5. Change preferredDomainController in mailbox move script # 6. Run mailbox move script: # CSV Example: # PrimarySMTPAddress,TargetDB # bloggsj,mytargetservername $path = "C:\MailboxMove\MbxsToBeMoved.csv"; Write-Host; Write-Host "*******************"; Write-Host "Move Mailbox Script" -Foregroundcolor Blue -Backgroundcolor White; Write-Host "*******************"; Write-Host; Write-Host "A CSV is required (i.e. $path)" $Ver1 = Read-Host "CONTINUE script execution? [Y] to continue or [ANY OTHER KEY] to exit" if ($Ver1 -ne "Y") {exit; } Write-Host; Write-Host "Valid entries in CSV:" -Foregroundcolor Blue -Backgroundcolor White; Write-Host; Write-Host "PrimarySMTPAddress,TargetDB"; Import-csv -path $path | foreach ` { $TDBs = Get-MailboxDatabase $_.TargetDB -ErrorVariable MyError -ErrorAction SilentlyContinue; $A = $_.PrimarySMTPAddress Write-Host "$A,$TDBS"; } If ($MyError -ne $null)` { Write-Host; Write-Host "*******"; Write-Host "Error" -Foregroundcolor Red -Backgroundcolor White; Write-Host "*******"; Write-Host "Invalid TargetDB in CSV. Script terminating..." -Foregroundcolor Blue -Backgroundcolor White; Write-Host "Error Description:" -Foregroundcolor Blue -Backgroundcolor White; $MyError; Write-Host; exit; } $Ver2 = Read-Host "CONTINUE moving ALL mailboxes in CSV? [Y] to continue or [ANY OTHER KEY] to exit" if ($Ver2 -ne "Y") {exit; } Function SendMPSRequest([string]$xmlRequestStr) { $oMpf = new-object -comobject "Provisioning.ProvEngineClient" $xmlResponseStr = $oMPF.SubmitTrustedRequest($xmlRequest.get_InnerXml()); $xmlResponse = new-object "System.Xml.XmlDocument"; $xmlResponse.LoadXml($xmlResponseStr); $xmlResponse; } [string]$xmlRequestStr = @" <?xml version="1.0" encoding="utf-8"?> <request> <data> <preferredDomainController>ad01.HMC.Local</preferredDomainController> <user>CSVPopulated</user> <targetDatabase>CSVPopulated</targetDatabase> </data> <procedure> <execute namespace="Hosted Email 2007" procedure="MoveMailbox" impersonate="1"> <before source="data" destination="executeData" mode="merge" /> <after source="executeData" destination="data" mode="merge" /> </execute> </procedure> </request> "@ [string]$excXmlStr = @" <?xml version="1.0" encoding="utf-8"?> "@ Write-Host Write-Host "Starting procedure..." -Foregroundcolor Blue -Backgroundcolor White; Write-Host $CSV = Import-csv -path $path Foreach ($line in $CSV)` { $mailbox = Get-Mailbox $line.PrimarySMTPAddress | Select PrimarySMTPAddress, DistinguishedName; Write-Host $line.PrimarySMTPAddress Write-Host $mailbox $userName = $mailbox.SameAccountName; $userDN = $mailbox.DistinguishedName; $TDB = $line.TargetDB Write-Host "Moving $userName to $TDB..." -ForegroundColor White Write-Host $xmlRequest = new-object "System.Xml.XmlDocument"; $xmlRequest.LoadXml($xmlRequestStr); $xmlRequest.request.data.user = "LDAP://" + $userDN; Write-Host $userDN; $xmlRequest.request.data.targetDatabase = $TDB; $xmlResponse = $null; $xmlResponse = SendMPSRequest($xmlRequestStr.ToString()); if ($xmlResponse.Response.Data.User -ne $null)` { $MPSUser = New-Object System.Object; $MPSUser | Add-Member -Type NoteProperty -Name "DistinguishedName" -Value $userDN; $MPSUser | Add-Member -Type NoteProperty -Name "User" -Value $xmlResponse.Response.Data.user; $MPSUser | Add-Member -Type NoteProperty -Name "TargetDB" -Value $xmlResponse.Response.Data.targetDatabase; $MPSUser | FL; } } Write-Host; Write-Host "********************************************************************************************************************************************************************************************"; Write-Host "Script execution complete. In pre-HMC4.0 Hosted Exchange Update Rollup 5 environments, please remember to run the Managed Email 2007::RepairExchangeObject procedure on all mailboxes moved." -Foregroundcolor Blue -Backgroundcolor White; Write-Host "********************************************************************************************************************************************************************************************"; Write-Host;
# 1. Use the Exchange Management Shell to get the source server name with Get-ExchangeServer | Select Name # 2. Use the Exchange Management Shell to populate the input CSV file with Get-MailboxDatabase | where {$_.ServerName.Contains("sourceservername") -eq "true"} | Get-Mailbox | Select PrimarySMTPAddress,Database | Export-Csv C:\Temp\MbxsToBeMoved.csv –NoTypeInformation # 3. Change ‘Database’ field header to ‘TargetDB’ # 4. Modify database/targetdb field entries as required in the CSV # 5. Change preferredDomainController in mailbox move script # 6. Run mailbox move script: # CSV Example: # PrimarySMTPAddress,TargetDB # bloggsj,mytargetservername $path = "C:\MailboxMove\MbxsToBeMoved.csv"; Write-Host; Write-Host "*******************"; Write-Host "Move Mailbox Script" -Foregroundcolor Blue -Backgroundcolor White; Write-Host "*******************"; Write-Host; Write-Host "A CSV is required (i.e. $path)" $Ver1 = Read-Host "CONTINUE script execution? [Y] to continue or [ANY OTHER KEY] to exit" if ($Ver1 -ne "Y") {exit; } Write-Host; Write-Host "Valid entries in CSV:" -Foregroundcolor Blue -Backgroundcolor White; Write-Host; Write-Host "PrimarySMTPAddress,TargetDB"; Import-csv -path $path | foreach ` { $TDBs = Get-MailboxDatabase $_.TargetDB -ErrorVariable MyError -ErrorAction SilentlyContinue; $A = $_.PrimarySMTPAddress Write-Host "$A,$TDBS"; } If ($MyError -ne $null)` { Write-Host; Write-Host "*******"; Write-Host "Error" -Foregroundcolor Red -Backgroundcolor White; Write-Host "*******"; Write-Host "Invalid TargetDB in CSV. Script terminating..." -Foregroundcolor Blue -Backgroundcolor White; Write-Host "Error Description:" -Foregroundcolor Blue -Backgroundcolor White; $MyError; Write-Host; exit; } $Ver2 = Read-Host "CONTINUE moving ALL mailboxes in CSV? [Y] to continue or [ANY OTHER KEY] to exit" if ($Ver2 -ne "Y") {exit; } Function SendMPSRequest([string]$xmlRequestStr) { $oMpf = new-object -comobject "Provisioning.ProvEngineClient" $xmlResponseStr = $oMPF.SubmitTrustedRequest($xmlRequest.get_InnerXml()); $xmlResponse = new-object "System.Xml.XmlDocument"; $xmlResponse.LoadXml($xmlResponseStr); $xmlResponse; } [string]$xmlRequestStr = @" <?xml version="1.0" encoding="utf-8"?> <request> <data> <preferredDomainController>ad01.HMC.Local</preferredDomainController> <user>CSVPopulated</user> <targetDatabase>CSVPopulated</targetDatabase> </data> <procedure> <execute namespace="Hosted Email 2007" procedure="MoveMailbox" impersonate="1"> <before source="data" destination="executeData" mode="merge" /> <after source="executeData" destination="data" mode="merge" /> </execute> </procedure> </request> "@ [string]$excXmlStr = @" <?xml version="1.0" encoding="utf-8"?> "@ Write-Host Write-Host "Starting procedure..." -Foregroundcolor Blue -Backgroundcolor White; Write-Host $CSV = Import-csv -path $path Foreach ($line in $CSV)` { $mailbox = Get-Mailbox $line.PrimarySMTPAddress | Select PrimarySMTPAddress, DistinguishedName; Write-Host $line.PrimarySMTPAddress Write-Host $mailbox $userName = $mailbox.SameAccountName; $userDN = $mailbox.DistinguishedName; $TDB = $line.TargetDB Write-Host "Moving $userName to $TDB..." -ForegroundColor White Write-Host $xmlRequest = new-object "System.Xml.XmlDocument"; $xmlRequest.LoadXml($xmlRequestStr); $xmlRequest.request.data.user = "LDAP://" + $userDN;
Write-Host $userDN;
$xmlRequest.request.data.targetDatabase = $TDB; $xmlResponse = $null; $xmlResponse = SendMPSRequest($xmlRequestStr.ToString()); if ($xmlResponse.Response.Data.User -ne $null)` { $MPSUser = New-Object System.Object; $MPSUser | Add-Member -Type NoteProperty -Name "DistinguishedName" -Value $userDN; $MPSUser | Add-Member -Type NoteProperty -Name "User" -Value $xmlResponse.Response.Data.user; $MPSUser | Add-Member -Type NoteProperty -Name "TargetDB" -Value $xmlResponse.Response.Data.targetDatabase; $MPSUser | FL; } } Write-Host; Write-Host "********************************************************************************************************************************************************************************************"; Write-Host "Script execution complete. In pre-HMC4.0 Hosted Exchange Update Rollup 5 environments, please remember to run the Managed Email 2007::RepairExchangeObject procedure on all mailboxes moved." -Foregroundcolor Blue -Backgroundcolor White; Write-Host "********************************************************************************************************************************************************************************************"; Write-Host;
In the next post I will cover 3rd and 4th steps for downsizing activity, this will be coming soon, so be tuned.
As a conclusion HMC downsizing activity need some planning and should be done carefully to avoid any risk that can affect the HMC production environment.
Related Posts:
Part1: http://blogs.technet.com/b/meamcs/archive/2012/11/11/downsizing-hmc-environment-to-prepare-for-exchange-2010-sp2-hosted-solution-part1.aspx
Part2: http://blogs.technet.com/b/meamcs/archive/2012/11/12/downsizing-hmc-environment-to-prepare-for-exchange-2010-sp2-hosted-solution-part2.aspx
Part3: http://blogs.technet.com/b/meamcs/archive/2012/11/19/downsizing-hmc-environment-to-prepare-for-exchange-2010-sp2-hosted-solution-part3.aspx