{"id":245,"date":"2019-02-21T04:17:39","date_gmt":"2019-02-21T09:17:39","guid":{"rendered":"http:\/\/itblog.ldlnet.net\/?p=245"},"modified":"2019-02-21T04:17:39","modified_gmt":"2019-02-21T09:17:39","slug":"moving-mailboxes-to-o365-via-powershell-in-hybrid-configuration","status":"publish","type":"post","link":"https:\/\/itblog.ldlnet.net\/index.php\/2019\/02\/21\/moving-mailboxes-to-o365-via-powershell-in-hybrid-configuration\/","title":{"rendered":"Moving mailboxes to O365 via PowerShell in Hybrid Configuration"},"content":{"rendered":"\n<p>As many of you have knowledge, I am studying for my MS-202 Exam. And, part of the knowledge needed is to be able to migrate mailboxes between on premises and Exchange Online through PowerShell. Here are the steps for the scenario to move a mailbox from on premises to O365:<\/p>\n\n\n\n<p class=\"has-small-font-size\"><strong>1.\u00a0Connect\u00a0to\u00a0Exchange\u00a0Online\u00a0via\u00a0PowerShell<\/strong><br><br>If you have read my previous post: <strong><em><a rel=\"noreferrer noopener\" aria-label=\"Connect to All PowerShell Modules in O365 with one script (opens in a new tab)\" href=\"http:\/\/itblog.ldlnet.net\/index.php\/2019\/02\/12\/connect-to-all-powershell-modules-in-o365-with-one-script\/\" target=\"_blank\">Connect to All PowerShell Modules in O365 with one script<\/a><\/em><\/strong><br>You should have all the settings needed to connect your PowerShell to O365. Note in this scenario, that all these cmdlets will be run from O365 PowerShell and will be monitored from O365 by either PowerShell or the Exchange Admin Center. You will not be able to monitor the moves from On-Premises.<\/p>\n\n\n\n<p class=\"has-small-font-size\"><strong>2. Provide your on premises Migration Administrator credentials as a variable for your cmdlet.<\/strong><\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\">$OnPremCred = Get-Credential -Message \"Enter the On Premises Exchange Migration Admin account creds\"<\/pre>\n\n\n\n<p class=\"has-small-font-size\"><strong>3.\u00a0Move\u00a0a\u00a0single\u00a0mailbox.<\/strong><br><br>In your hybrid configuration you should be doing directory sync with O365\/Azure and the accounts should be available in the cloud showing that they are synced with AD. This also assumes that you have your MRS Proxy endpoint enabled, which can be done by the HCW. Also, make sure you have your licensing available for your mailboxes. From my knowledge, you can assign your license to the account in the cloud before moving, especially if you have a particular license that you need to assign the account. Other than that, moving the mailbox will assign an existing license that is available that includes an Exchange Online mailbox feature when the mailbox is moved.<br>Now we initiate the move with the cmdlet. Similar to what you would do in the GUI, this simple mailbox move cmdlet initiates the move request. It has most of the same parameters as a local move request including BadItemLimit, LargeItemLimit, AcceptLargeDataLoss, etc&#8230;<br>\u00a0<br>Use the following <em><strong><a rel=\"noreferrer noopener\" aria-label=\"LINK (opens in a new tab)\" href=\"https:\/\/docs.microsoft.com\/en-us\/powershell\/module\/exchange\/move-and-migration\/new-moverequest?view=exchange-ps\" target=\"_blank\">LINK<\/a><\/strong><\/em>\u00a0for\u00a0documentation\u00a0on\u00a0the\u00a0<strong>New-MoveRequest\u00a0<\/strong>cmdlet.<\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\" title=\"Move a single on premises mailbox to O365\">#Set the identity of the mailbox being moved\n$user = Read-Host \"Enter the alias or E-Mail Address of the user being migrated: \"\n\n#Next Run the cmdlet for the New Mailbox Move Request\nNew-MoveRequest -Identity $user -remote -RemoteHostName (hybridURL) -TargetDeliveryDomain companyname.mail.onmicrosoft.com -RemoteCredential $OnPremCred -AcceptLargeDataLoss -BadItemLimit 500 -LargeItemLimit 100 -BatchName \"$user Mailbox Move to O365\"\n\n#Get the status of the mailbox move to completion\nGet-MoveRequest | ? {$_.alias -eq \"$user\"} | Get-MoveRequestStatistics | fl\n<\/pre>\n\n\n\n<p>Now with all migration projects, we expect to have to move multiple mailboxes in a single batch. The following will show the process for moving mailboxes in bulk from on premises to O365:<\/p>\n\n\n\n<p class=\"has-small-font-size\"><strong>1.\u00a0Connect\u00a0to\u00a0Exchange\u00a0Online\u00a0via\u00a0PowerShell<\/strong><br><br>If you have read my previous post: <strong><em><a rel=\"noreferrer noopener\" aria-label=\"Connect to All PowerShell Modules in O365 with one script (opens in a new tab)\" href=\"http:\/\/itblog.ldlnet.net\/index.php\/2019\/02\/12\/connect-to-all-powershell-modules-in-o365-with-one-script\/\" target=\"_blank\">Connect to All PowerShell Modules in O365 with one script<\/a><\/em><\/strong><br>You should have all the settings needed to connect your PowerShell to O365. Note in this scenario, that all these cmdlets will be run from O365 PowerShell and will be monitored from O365 by either PowerShell or the Exchange Admin Center. You will not be able to monitor the moves from On-Premises.<\/p>\n\n\n\n<p class=\"has-small-font-size\"><strong>2. Provide your on premises Migration Administrator credentials as a variable for your cmdlet.<\/strong><\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\">$OnPremCred = Get-Credential -Message \"Enter the On Premises Exchange Migration Admin account creds\"<\/pre>\n\n\n\n<p class=\"has-small-font-size\"><strong>3.\u00a0Move\u00a0multiple\u00a0mailboxes in a single batch.<\/strong><br><br>In your hybrid configuration you should be doing directory sync with O365\/Azure and the accounts should be available in the cloud showing that they are synced with AD. This also assumes that you have your MRS Proxy endpoint enabled, which can be done by the HCW. Also, make sure you have your licensing available for your mailboxes. From my knowledge, you can assign your license to the account in the cloud before moving, especially if you have a particular license that you need to assign the account. Other than that, moving the mailbox will assign an existing license that is available that includes an Exchange Online mailbox feature when the mailbox is moved.<br><br>This time you want to create a CSV file using the <em>alias or emailaddress<\/em> as your header and then list the appropriate value for all the users in your batch group. Save the file locally as <em>MigrationBatch01.csv\u00a0<\/em>or\u00a0a\u00a0name\u00a0of\u00a0your\u00a0choice.<br><\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"177\" height=\"208\" src=\"http:\/\/itblog.ldlnet.net\/wp-content\/uploads\/2019\/02\/CSVCreation.png\" alt=\"\" class=\"wp-image-246\"\/><figcaption>Use EMailAddress<br><strong>\u00a0OR<\/strong><br><strong>\u00a0<\/strong>Alias\u00a0as\u00a0the\u00a0header<\/figcaption><\/figure><\/div>\n\n\n\n<p class=\"has-small-font-size\">Next you initiate the mailbox moves. When specifying the mailbox identity in the cmdlet, use the respective header in your variable declaration (either <strong>$user.EMailAddress<\/strong> OR <strong>$user.Alias<\/strong>)<br> <br>Use the following <em><strong><a rel=\"noreferrer noopener\" href=\"https:\/\/docs.microsoft.com\/en-us\/powershell\/module\/exchange\/move-and-migration\/new-moverequest?view=exchange-ps\" target=\"_blank\">LINK<\/a><\/strong><\/em>\u00a0for\u00a0documentation\u00a0on\u00a0the\u00a0<strong>New-MoveRequest\u00a0<\/strong>cmdlet. <\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\" title=\"Move multiple on premises mailboxes to O365 in a Batch\">#Import the CSV into the variable state\n$mailboxes = Import-CSV C:\\Migration\\MigrationBatch01.csv\n\n#Next Run the cmdlet for the New Mailbox Move Request to move each mailbox\nforeach ($user in $mailboxes) { New-MoveRequest -Identity $user.EMailAddress -remote -RemoteHostName (hybridURL) -TargetDeliveryDomain companyname.mail.onmicrosoft.com -RemoteCredential $OnPremCred -AcceptLargeDataLoss -BadItemLimit 500 -LargeItemLimit 100 -BatchName \"Migration Batch 01 Moves to O365\" }\n\n#Get the status of the mailbox moves in the batch to completion\nGet-MoveRequest | ? {$_.batchname -like \"Migration Batch 01 Moves to O365\"} | Get-MoveRequestStatistics | ft -a -wr\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"text-align:center\">GOOD LUCK WITH YOUR MIGRATIONS!<br>HAPPY TROUBLESHOOTING!<\/h2>\n\n\n\n<p class=\"has-small-font-size\"><strong><em>References:<\/em><\/strong><br><strong><a rel=\"noreferrer noopener\" aria-label=\"Moving Individual Mailboxes to O365 (opens in a new tab)\" href=\"https:\/\/oddytee.wordpress.com\/2015\/06\/30\/moving-individual-mailboxes-to-office-365-via-powershell\/\" target=\"_blank\">Moving Individual Mailboxes to O365<\/a><\/strong><br><strong><a rel=\"noreferrer noopener\" aria-label=\"Move Mailboxes in Bulk to O365 (opens in a new tab)\" href=\"https:\/\/oddytee.wordpress.com\/2015\/02\/13\/moving-mailboxes-in-bulk-to-office-365\/\" target=\"_blank\">Move Mailboxes in Bulk to O365<\/a><\/strong><br><strong><a rel=\"noreferrer noopener\" aria-label=\"PowerShell Mailbox Migration to O365  (opens in a new tab)\" href=\"https:\/\/www.coyotecrk.com\/powershell-migration-office-365\/\" target=\"_blank\">PowerShell Mailbox Migration to O365<\/a><\/strong><br><strong><a rel=\"noreferrer noopener\" aria-label=\"Connect to all PowerShell Modules in O365 with one script (opens in a new tab)\" href=\"http:\/\/itblog.ldlnet.net\/index.php\/2019\/02\/12\/connect-to-all-powershell-modules-in-o365-with-one-script\/\" target=\"_blank\">Connect to all PowerShell Modules in O365 with one script<\/a><\/strong><br><strong><a href=\"https:\/\/docs.microsoft.com\/en-us\/powershell\/module\/exchange\/move-and-migration\/new-moverequest?view=exchange-ps\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"New-MoveRequest Microsoft Document (opens in a new tab)\">New-MoveRequest Microsoft Document<\/a><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As many of you have knowledge, I am studying for my MS-202 Exam. And, part of the knowledge needed is to be<\/p>\n<p class=\"link-more\"><a class=\"myButt \" href=\"https:\/\/itblog.ldlnet.net\/index.php\/2019\/02\/21\/moving-mailboxes-to-o365-via-powershell-in-hybrid-configuration\/\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":209,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,2,3],"tags":[105,15,9,78,110,109,108,8,13],"class_list":["post-245","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-exchange","category-general","category-powershell","tag-cmd","tag-cmdlet","tag-exchange","tag-exchange-onlilne","tag-mailbox","tag-mailbox-migration","tag-migration","tag-powershell","tag-script","odd"],"_links":{"self":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/245","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/comments?post=245"}],"version-history":[{"count":1,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/245\/revisions"}],"predecessor-version":[{"id":247,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/245\/revisions\/247"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/media\/209"}],"wp:attachment":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/media?parent=245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/categories?post=245"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/tags?post=245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}