logo

powershell script to move mailboxes across organization in bulk

Amy posted on Thursday, June 28, 2007 6: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.

Bharat Suneja [MVP] posted on Thursday, June 28, 2007 9: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

Amy posted on Thursday, June 28, 2007 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


Didn't Find The Answer You Were Looking For?

EggHeadCafe has experts online right now that may know the answer to your question.  We pay them a bonus for answering as many questions as they can.  So, why not help them and yourself by becoming a member (free) and ask them your question right now?
Create Account & Ask Question In Live Forum





Pete's Resume  |  Robbe's Resume  |  Neado  |  Free Icons  |  Privacy  |   (c) 2010