MoveMBsToTargetMD
(1)
NTAccountOU
(1)
SourceForestGlobalCatalog
(1)
TargetForestCredential
(1)
SourceForestCredential
(1)
TargetOU
(1)
TargetCredential
(1)
SourceCredential
(1)

powershell script to move mailboxes across organization in bulk

Asked By Amy
28-Jun-07 06:16 PM
I found a beautiful script http://www.exchangeninjas.com/MoveMBsToTargetMD
to move mailboxes in an Exchange 2007 organization using a .csv file for
input.  I would like to do the same thing, but move these mailboxes from one
Exchange organization (2003) to another Exchange organization (2007).  The
regular command to do this from a command line looks like this:

move-mailbox -TargetDatabase "Mercury\First Storage Group\Mailbox
Database" -identity user1 -GlobalCatalog
$SourceCredential -TargetForestCredential $TargetCredential

I would like to see if anyone has a way that I can run this from a .ps1
script but use a .csv file as input for the -Identity parameter.  Any help
would be greatly appreciated!

CSV (MoveMailboxes.

Asked By Bharat Suneja [MVP]
28-Jun-07 09:08 PM
CSV (MoveMailboxes.csv) fields:
Username, TargetDatabase, TargetOU

(You can leave out the TargetDatabase and TargetOU if all moved mailboxes
will be in the same OU and on the same target Store... and use those
references in the command instead of having them in the CSV).

$SourceCredential = Read-Host "Enter Source Forest
Credentials" -AsSecureString
$TargetCredential = Read-Host "Enter Target Forest
Credentials" -AsSecureString

Import-CSV MoveMailboxes.csv | foreach {Move-Mailbox -Identity
$_.Username -TargetDatabase $_.TargetDatabase -NTAccountOU
_.TargetOU  -SourceForestGlobalCatalog "mctdc1.test.net" -GlobalCatalog
$SourceCredential -TargetForestCredential $TargetCredential}

--
Bharat Suneja
MVP - Exchange
www.zenprise.com
NEW blog location:
exchangepedia.com/blog
------------------------------

Thank you so much Bharat, I have something very similar to this but mine isnt

Asked By Amy
28-Jun-07 10:41 PM
Thank you so much Bharat,  I have something very similar to this but mine
isnt as elegant as yours, as I didnt allow for the SourceCredential and
TargetCredential - I was running those manually inside the shell before I
spun off my script.... my one problem, and I think this script here will
have it too... how do you pipe the Yes at the end of each mailbox that it is
going to move?  I have tried every trick I know from my batch scripting....

Thanks

amy
Post Question To EggHeadCafe