Link to home
Start Free TrialLog in
Avatar of compdigit44
compdigit44

asked on

Exchange 2003 to Exchange 2010 Mailbox Moves

The experts in the Exchange forum help me build the following powersheel script...

MBX = get-mailbox -Database "Server1\Second Storage Group\Mail Store (Server)"
$MBX | ./MoveMailbox.ps1 -targetdatabase "Server2\Mailbox Database 0446449042" -Whatif

My new exchange server is Exchange 2010 Sp1. My goal is to schedule these mailbox moves off hours have have the move request automatically cleared.

Wht I run the aboce command I keep getting and error stating -whatif is not a vaild parameter.
Avatar of ckeshav
ckeshav

You can schedule it even from the EMC, Select the mailboxes which you want to move and in the Move schedule windows select instead of immediately select the time.

You can do different selection by opening new windows
Avatar of compdigit44

ASKER

Really???
Avatar of Jamie McKillop
Hello,

There are a couple of syntax issues with the script. Here is how I would write it:

get-mailbox -Database "Server1\Second Storage Group\Mail Store (Server)" | .\MoveMailbox.ps1 -targetdatabase "Server2\Mailbox Database 0446449042" -Whatif

The -whatif switch executes the script without making any changes. You should remove this switch when you are ready to run the script and have it actually move the mailboxes.

JJ
Thanks Everyone.. But I'm interested to know if these 2003 to 2010 mailboxes moves can be scheudle of queued up using the GUI??? If I were to setup a new Local Move request and select suspend from what I have read, it would appear the wizard completes and the moves would like look likw it was moved but when you check the Move REquest it is QUEUED, How could I setup the move to finish the move starting at a specific time.
When you use the GUI, you will be presented with the option to move the mailbox now or schedule the move in the future. Simply enter the date and time you want to move to start and it will wait until that time.

JJ
I have given the simple solution in my first. Try moving 1 or 2 Mailbox from EMC.
WIll I need to click on NEW in the move request wizard in order to see the schedule screen.
CAn you send me a screen shot
OK, I see you are running Exchange 2010. Unfortunately, you cannot schedule moves either in the GUI or directly in the powershell command. What you would need to do to schedule the move at a specific time is to either build the scheduling into your powershell script or use Windows scheduler to run the script at a specific time.

JJ
Now I'm confused I have one person saying YES and the other person saying NO...

What is the purpose the the Suspend move request then?
With 2007 you could schedule the time the move would would take place but with 2010, you cannot.

The purpose of the suspend command is to move all the initial content to the new server but the mailbox isn't locked down and switched to the new location until the move is resumed.

JJ
Wait a second the the suspend request be schedule to resume at a specific time???
No, it cannot directly. You would need to script that or use Windows Scheduler to run the scripts at a specific time.

JJ
What you you suggest to do use the powershell script you list earlier to use a script to clear the move request???

Please help not very good in powershell
Regarding the script that was posted..

get-mailbox -Database "Server1\Second Storage Group\Mail Store (Server)" | .\MoveMailbox.ps1 -targetdatabase "Server2\Mailbox Database 0446449042" -Whatif


I was told I would need a variable becuase that is what the ./movemailbox.ps1 needed?
How could I only move 10 mailboxes at a time?
Where should I save this PSQ to I can schedule it via task scheduler?
Will this clear the move requst?
What will happen if a corrupted message it encountered?
You don't need a variable. If you look at Example 1 here - http://technet.microsoft.com/en-us/library/dd876878.aspx you will see they are piping get-mailbox directly to movemailbox.ps1

You can use the -startbatchsize switch to move mailboxes in group of any number.

Move requests are cleared once complete. You genreally talk about clearing the move request if you are going to use the suspend switch.

If a corrupt item is encountered, the move will fail. You can use the -BadItemCount switch to specify a number of corrupt items to skip.

Here is a powershell script you could use to schedule it. Set whatever you want in the $MoveTime Variable.

$MoveTime = "Tuesday, May 03, 2011 11:00:00 PM"
$MoveTime = [datetime]::Parse(($MoveTime))

Do {
    $Now = Get-Time
}
While ($Now -lt $MoveTime)

get-mailbox -Database "Server1\Second Storage Group\Mail Store (Server)" | .\MoveMailbox.ps1 -targetdatabase "Server2\Mailbox Database 0446449042"

JJ

WOW!!!!
I would save this as a PS1 file correct? Does it matter where I save the file? Desktop, root of C:\ drive??
If a corrupt mailbox is encounter with all mailbox moves fail or will the move move onto the next mailbox?
Where would I use the -whatif command. Will this command should we which mailbox would have been moved?
Yes, you would save it as a ps1. It doesn't matter where you save it. You just right-click the file a select Run in Powershell. If a corrupt item is encountered, it will move on to the next mailbox. You don't use the -whatif switch unless you want to test the script without it actually doing anything. In that case, just add it to the end of the line that starts with get-mailbox

JJ
The following article stats that I could use task schedule to schedule the start time of a powershell script.. How would i do with wit the scritp you wrote above?

Does it matter where I save the script?
When I copy and paste the following into notepad and save it as a PS1 file I gett the message .\Movemailbox.ps1 is not a recongized cmdlet..... I saved my PS1 file to the root of my C:\ drive..

get-mailbox -Database "Server1\Second Storage Group\MBX1" | .\MoveMailbox.ps1 -targetdatabase

"Server2\Mailbox Database 0446449042" -Whatif
Save both the script and MoveMailbox.ps1 to C:\Windows\System32\WindowsPowerShell\v1.0

If you are going to use task scheduler, you don't need the full script I wrote. The point of that script is to run it at any time and it will wait until the predefined time to run the command. If you want to use task scheduler, just create a .ps1 with the following line:

get-mailbox -Database "Server1\Second Storage Group\Mail Store (Server)" | .\MoveMailbox.ps1 -targetdatabase "Server2\Mailbox Database 0446449042"

Now, create a batch file with the line:

powershell -command "& 'c:\windows\system32\windowspowershell\v1.0\script.ps1' "

Go into task scheduler and setup a task to run the batch file whenever you want it to move the mailboxes.

JJ
If I include the Whatif command will this list out all of the mailboxes that would have been moved?
Also How would use this script to move mailboxes in batches of 10
I'm not sure if it will show you which mailboxes would be moved. Give it a try.

If you want to move in batches of 10, this would be the command:

get-mailbox -Database "Server1\Second Storage Group\MBX1" | .\MoveMailbox.ps1 -targetdatabase "Server2\Mailbox Database 0446449042" -startbatchsize 10

JJ
I keeping getting the message A parameter cannot be found with  -whatif ???
The command may not support the -whatif switch.

JJ
what is the suppose command then to simulate mailbox moves in 2010 Sp1
You won't be able to simulate the moves using the MoveMailbox.ps1 script.

JJ
Could I do this may be??????

get-mailbox -Database "Server1\Second Storage Group\MBX1" -whatif | .\MoveMailbox.ps1 -targetdatabase "Server2\Mailbox Database 0446449042" -startbatchsize 10

The whatif isn't necessary in that situation since get-mailbox doesn't make any changes. If you just want to verify which mailboxes will be returned, just run the get-mailbox portion of the command which will output the results to the screen.
OK.. but when I am ready the whole command should work correct?

get-mailbox -Database "Server1\Second Storage Group\MBX1" | .\MoveMailbox.ps1 -targetdatabase "Server2\Mailbox Database 0446449042" -startbatchsize 10

When I run the get-mailbox -databae command I keep getting database cannot be found
So, you ran this command: get-mailbox -Database "Server1\Second Storage Group\MBX1" making sure the server, storage group, and database name match what is actually in your environment?

JJ
If I use the get-mailbox -server command I get a list of mailboxes but this stinks becuase I have 5 DB on my 2003 server and each mailbox goes into a different DB on the 2010 server and thoughts around this.
The information is correct.. Is it becuase 2010 no longer has Storage Groups???????
Server1\Second Storage Group\MBX1 should be the source database, so that would be your Exchange 2003 server.

The script you have is going to move all mailboxes from a single database on your 2003 server to a single database on your 2010 server. You need to modify and run the script for each database. If you are not looking to do a one-to-one mapping between the servers, the script will need to be written to accomodate how you want to distribute the mailboxes on the 2010 server.

JJ
OK I think I have my final script writen now.... Does there have to be a space inbetween the pipe and next command.. How does this script look...

get-mailbox -Database "server11\First Storage Group\Mailbox Store (store) -resultsize 30
| .\MoveMailbox.ps1 -targetdatabase "server2\Mailbox Database" -BadItemlimit 30
Why have you added the resultsize switch? This will cause the command to only return the first 30 mailboxes. If you want to move only 30 mailboxes at a time, this would be fine.

It otherwise looks fine except that it all needs to be on one line.

JJ
Correct I only want to move 30 mailboxes at a time so this is ok then right?
why does everything have to be on one line?
Yes, this should work they way you want.

JJ
ASKER CERTIFIED SOLUTION
Avatar of Jamie McKillop
Jamie McKillop
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial