Friday, June 11, 2010

Mailbox Migration to Exchange 2010 (PowerShell)

As stated in my previous post, I am no scripting guru or will I ever claim to be.  My primary purpose for creating this script is to force myself to learn about PowerShell scripting. 

I am sure that there is a more efficient or better approach here, so please leave comments and let me know.

The following script is written to migrate mailboxes (from Exchange 2003, 2007, or 2010) to an Exchange 2010 database.  This script could easily be modified if your target database was on Exchange 2007, but for now it is just written for Exchange 2010.

##########################################################################
# This script is for migrating mailboxes to Exchange 2010
# There is no warranty, use at your own risk
# Author: Tim Harrington
http://HowDoUC.blogspot.com
#
# Some of the methods in this script rely on Quest AD PowerShell Commands
# Free download at
http://www.quest.com/powershell/activeroles-server.aspx
##########################################################################

# Initial Menu to select method of selecting mailboxes to move
#
Write-Host " "
Write-Host "1 = Move mailboxes by user name"
Write-Host "2 = Move mailboxes by security group"
Write-Host "3 = Move mailboxes by database"
Write-Host "4 = Move mailboxes by OU"
Write-Host " "
Write-Host "Full Report = Run Report -> c:\temp\FullMoveReport.txt"
Write-Host "Error Report = Run Report -> c:\temp\ErrorMoveReport.txt"
Write-Host " "
$Method = Read-Host "Please select an option from the list above?"
#
# Method 1 = Move mailboxes by user name
If ($Method -eq 1)
{
Write-Host "You have choosen to migrate mailboxes by specifying the user name"
Get-MailboxDatabase
$TargetDatabaseName = Read-Host "Type the database that you want to migrate user(s) to"
$UserName = Read-Host "Type the user name that will be migrated"
Write-Host ("Moving user: " +$UserName +" to database: " +$TargetDatabaseName)
New-MoveRequest -identity $UserName -TargetDatabase $TargetDatabaseName
}

# Method 2 = Move mailboxes by security group
If ($Method -eq 2)
{
Write-Host " "
Write-Host "You have choosen to migrate mailboxes by specifying an AD security group"
Write-Host " "
Write-Host "This script relies on Quest AD PowerShell Commands"
Write-Host "Download at http://www.quest.com/powershell/activeroles-server.aspx"
Write-Host " "
Add-PSSnapin Quest.ActiveRoles.ADManagement
$ADSecGroupName = Read-Host "Enter AD security group that you want to migrate"
Get-QADUser -MemberOf $ADSecGroupName | ft
Write-Host "The above list of users will get migrated!!"
Write-Host " "
Get-MailboxDatabase | ft
$TargetDatabaseName = Read-Host "Type the database that you want to migrate user(s) to"

#Loop through each mailbox
foreach ($mailbox in (Get-QADUser -MemberOf $ADSecGroupName))
{$displayname = $mailbox.Displayname
New-MoveRequest -Identity $displayname -TargetDatabase $TargetDatabaseName}
}
#
# Method 3 = Move mailboxes by database
If ($Method -eq 3)
{
Write-Host "You have choosen to migrate mailboxes from one database to another database"
Get-ExchangeServer | ft
$SourceServer = Read-Host "What is the source server from list above?"
Get-MailboxDatabase -Server $SourceServer | ft
$SourceDatabaseName = Read-Host "What is the SOURCE database from list above? (Type exactly from list)"
Get-MailboxDatabase | ft
$TargetDatabaseName = Read-Host "What is the TARGET database from list above? (Type exactly from list)"
Write-Host ("Moving users from source database: " +$SourceDatabaseName +" to target database: " +$TargetDatabaseName)
Get-Mailbox -Database $SourceDatabaseName
New-MoveRequest -TargetDatabase $TargetDatabaseName
}
#
# Method 4 = Move mailboxes by OU
If ($Method -eq 4)
{
Write-Host " "
Write-Host "You have choosen to migrate mailboxes by specifying an AD OU"
Write-Host " "
Write-Host "This script relies on Quest AD PowerShell Commands"
Write-Host "Download at http://www.quest.com/powershell/activeroles-server.aspx"
Write-Host " "
Add-PSSnapin Quest.ActiveRoles.ADManagement
Get-QADObject -Type OrganizationalUnit | ft
$ADOUName = Read-Host "Enter AD OU that you want to migrate"
Get-QADUser -Searchroot $ADOUName -SearchScope OneLevel | ft
Write-Host "The above list of users will get migrated!! (This does not include sub-OUs)"
Write-Host " "
Get-MailboxDatabase | ft
$TargetDatabaseName = Read-Host "Type the database that you want to migrate user(s) to"

#Loop through each mailbox
foreach ($mailbox in (Get-QADUser -Searchroot $ADOUName))
{$displayname = $mailbox.Displayname
New-MoveRequest -Identity $displayname -TargetDatabase $TargetDatabaseName}
}
#
# Save off full report
If ($Method -eq "Full Report")
{
Get-MoveRequest | Get-MoveRequestStatistics | Select DisplayName, Status, TotalItemSize, TotalMailboxItemCount, PercentComplete, BytesTransferred, ItemsTransferred | Out-File -FilePath "c:\temp\FullMoveUserLog.txt" -append -noClobber
}

# Save off error report
If ($Method -eq "Error Report")
{
Get-MoveRequest | Get-MoveRequestStatistics where {$_.Status -like "*error*"} | Select DisplayName, Status, TotalItemSize, TotalMailboxItemCount, PercentComplete, BytesTransferred, ItemsTransferred | Out-File -FilePath "c:\temp\ErrorMoveUserLog.txt" -append -noClobber
}
#############################################################################

Hope this helps some folks out there.  Comments are welcome.

26 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Thanks for sharing this information. But the article is targeting migration into Exchange 2010 mailboxes. But I tried the above mentioned way too for migration into Exchange 2013 from 2007, but couldn't get success.
    Therefore I went for a utility of Exchange Migration. But in the process of finding a utility, I came to know that it isn't possible to migrate mailboxes directly from one exchange server to another. Therefore I followed the way to Export Exchange mailboxes into PST and then import all PST files into another exchange server, and then configured all services like OWA, ECP etc in a proper manner.
    It was really an effortless way of migration with export & import mailbox technique by using Exchange recovery tool.

    ReplyDelete
  3. Really good article, It provides the step by step guide to exchange server 2007 sp3and I saw more information about this topic from https://softcart.wordpress.com/exchange-server-migration/ that helps to migrate any exchange server to exchange server.

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. As stated in my previous post, I am no scripting guru or will I ever claim to be. My primary purpose for creating this script is to force myself to learn about PowerShell scripting. wholesale apparel , bulk white t shirts canada , wholesale t shirts with free shipping , low cost t shirts wholesale , cheap bulk blank shirts , bulk grey t shirts , bulk childrens clothing , discount designer baby clothes , cheap dresses for kids , buy baby clothes

    ReplyDelete
  6. Mozocare in india's biggest medical tycoon are providing medical information about best ent surgeon. They write a blog blog on the top notch ENT Surgeons and Doctors. for more details you may visit :

    Treattments In Turkey

    ReplyDelete
  7. children's favorites happy birthday song mp3 download, best happy birthday song download, happy birthday song in hindi mp3 download, best happy birthday song download, happy birthday to you original song download, birthday song download, i wish you happy birthday song mp3 download, birthday shayari

    Children Favorites Happy Birthday Song Mp3 Download

    ReplyDelete
  8. Good evening. Good evening. I have wanted to write this service analysis. It really shocked me, actually, because I did not see the best of its kind compared to related places of dating this, where I could find my second half. This place will still encourage you to find your love, because it helped me one time. romanian brides The website is built in a very beautiful way so the functionality of this site is really rich and just, the website just surprised me with pleasure. I recommend this place to a lot of single guys!

    ReplyDelete

  9. We are helping amazon seller's to reinstate their suspended seller account. Aplus global ecommerce is guide companies to write perfect amazon appeal letter and full proof amazon suspension appeal.

    amazon suspension appeal

    ReplyDelete
  10. Oh, thanks so much! Glad you found it on dotcomsecrets, clicked, read, and commented! �� About Shoulder Replacement Surgery in India

    ReplyDelete
  11. Definitely a technical and coding help you left for us. Though it's 2021 and things are on its rapid changes, I found it still useful. I am also not a guy with rich scripting knowledge but I would like to agree, you did really an awesome job particularly those who would like to customize and migrating their mailbox. This is incredibly adorable. Much appreciation for sharing this handy project. I also would like to share an article Getnewmailbox especially those those guys who are looking for about how digital mailboxes work and compare the benefits to choose the best virtual mailbox service. Hope some readers here will find this useful.

    ReplyDelete
  12. Yeah, mailbox migration to porwershell script. This is really an amazing technical support. Anyway, as a business owner, surely you like to find your business into a growing trend. To get this growth you of course need some IT support of course with professional hands. IT company Pickering can be that hand to grab the best success, It provides optimal Infrastructure Technology solutions that are customized to your company needs.

    ReplyDelete
  13. Hi.....
    The RemoteLegacy switch specifies that this mailbox move is from a remote forest that has only Exchange 2010 servers installed. You don't need to specify a ...
    You are also read more About Home Loan

    ReplyDelete
  14. Bone Marrow Transplant Hospitals In Turkey
    Searching Cancer Treatment in Turkey. Here is the list of Best cancer hospitals in turkey contact us for any help to get affordable cancer treatment.

    ReplyDelete


  15. Chelsea chauffeur service is available to streamline and de-stress your city travel, with professional chauffeurs, London chauffeurs Heathrow chauffeur service and a fleet of safe, stylish modern cars.

    ReplyDelete

  16. Best MIG Welder under $500
    Most cross-dominant people choose a bow that goes with their handedness (lefties get a left-handed bow, righties get a right-handed bow), because that feels easiest, and they’re able to aim using a scope—but it’s up to you.

    ReplyDelete



  17. Bow Advisor For those who like the bow to match their style, this option is ideal as it comes in a diverse range of colors. The Diamond by Bowtech Deploy SB R.A.K. Compound Bow:Diamond Archery Deploy SB Compound Bow - 70 lbs,

    ReplyDelete

  18. Vi fik en dejlig oplevelse på min første dag som pensionist.. En rigtig god start på et nyt liv med indisk mad amager super god indisk mad lavet og serveret af den sødeste familie, der består af far og mor i køkkenet og datter og søn i restauranten.
    Hence, from the introductory paragraph, dissertation writers for hire to the ending of the essay we take care of your assignment.

    ReplyDelete
  19. Thank you for posting the script. You can try using EdbMails Exchange migration tool. It supports the migration of Exchange 2003 to 2019 server with zero down time. You can migrate your complete mailbox from your source Exchange server to Target Exchange server Office 365.
    Try EdbMails Exchange migration tool for free.

    ReplyDelete
  20. Stone Well Financial knows the ins and outs of assurance maladie étudiant étranger canada. Their expertise is unmatched.

    ReplyDelete
  21. When it comes to high-pressure piping applications, piping flanges
    stands out as the trusted source for top-quality flanges. Their flanges are meticulously crafted from durable materials, ensuring they can withstand even the most demanding conditions. Whether you're dealing with extreme temperatures, corrosive environments, or high-pressure fluids, Piping Flanges has the flanges you need to keep your piping system running smoothly and safely.

    ReplyDelete
  22. Impressed with Wifi Hire's event event wifi rental! The ease of booking, quick setup, and robust connection are exactly what you need for a successful event. Highly recommended!

    ReplyDelete
  23. This comment has been removed by the author.

    ReplyDelete
  24. Uphold integrity and trust within your organization with RocketBear's Ethical conduct video solutions! Their expertly crafted videos provide invaluable guidance on ethical decision-making, professional conduct, and compliance with ethical standards.

    ReplyDelete