header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Exchange 2007 Multi threaded Move to another random database on another server
Last Post 29 Jul 2010 08:28 AM by Karl Mitschke. 1 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Not Resolved
mdgrayUser is Offline
New Member
New Member
Posts:7
Avatar

--
28 Jul 2010 10:50 PM
    Hi, We are currently beginning a transistion to Exchange 2010. We are also consolidating a number of Exchange Servers that are geographically dispersed and need to move account to the data centre. I have developed the following code that works moving accounts from a file.

    Get-Content c:\ExchangeScripts\Migrate_Staff\staff.csv | Get-Mailbox | Move-Mailbox -TargetDatabase TASM-EXM8\TASMDB16 -Confirm:$false -MaxThreads 6 | out-file -append c:\ExchangeScripts\Migrate_Staff\migration.log

    This works quite well however the previous version that could randomly select one of the eight Databases on two server and move the user to that DB. Below is that code.

    $error.clear()
    $File_Import = Import-CSV "c:\ExchangeScripts\Migrate_Staff\staff.csv"
    $DB = ("TASM-EXM7\TASMDB10","TASM-EXM7\TASMDB11","TASM-EXM7\TASMDB12","TASM-EXM7\TASMDB13","TASM-EXM8\TASMDB14","TASM-EXM8\TASMDB15","TASM-EXM8\TASMDB16","TASM-EXM8\TASMDB17");
    "-> Begine Processing"
    foreach($_.Name in $File_import) { "-> Processing User $_.Name"
    $chosen_database = $DB | Get-Random;
    Move-Mailbox -Identity $_.Name -TargetDatabase $chosen_database -MaxThreads 4 -Confirm:$false | out-file -append c:\ExchangeScripts\Migrate_Staff\migrate.log
    }
    $error | out-file c:\ExchangeScripts\Migrate_Staff\error.log

    I know the answer is slapping me in the face but I just can't seem to get concurrent account moves going to random db's. Anyone got any ideas? Any help would be greatly appreciated.

    Karl MitschkeUser is Offline
    Basic Member
    Basic Member
    Posts:451
    Avatar

    --
    29 Jul 2010 08:28 AM
    Your $_.Name variable contains extra garbage:
    Processing User @{Name=Mitschke, Karl}.Name

    I'd do this:
    foreach($line in $File_import) { $Name = $line.name
    "-> Processing User $Name"}

    Now, this can be simplified a bit:

    foreach($line in Import-CSV "c:\ExchangeScripts\Migrate_Staff\staff.csv") { $Name = $line.name
    "-> Processing User $Name"

    Karl





    http://unlockpowershell.wordpress.com
    Co-Author, Windows PowerShell 2.0 Bible
    -join("6B61726C6D69747363686B65406D742E6E6574"-split"(?<=\G.{2})",19|%{[char][int]"0x$_"})
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer