Move mailboxes between stores reading the user names in a txt file.Exchange 2007 . Powershell script or Vbs

bsharath
bsharath used Ask the Experts™
on
Hi,

Move mailboxes between stores reading the user names in a txt file.Exchange 2007 . Powershell script or Vbs

Any help with a script that can move a user whose name is in a txt file into a specific Store.

Regards
sharath
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Chris DentPowerShell Developer
Top Expert 2010

Commented:
Hey,

It shouldn't be any more complex than this:


Get-Content YourFile.txt | ForEach-Object {
  Move-Mailbox $_ -TargetDatabase "server\storagegroup\store"
}


Uses Exchange 2007 management shell (Move-Mailbox). You may need to add the BadItemCount parameter that tends to be the most common issue with a move.

Chris

Author

Commented:
Thanks Chris
Should i have full names or samaccount names in the txt file
And badiremcount. where should i mention this

Can i have a log for success and failures
If the move failes hope there will be no issue on the mailbox?
Chris DentPowerShell Developer
Top Expert 2010

Commented:
SamAccountName would be best, it's unique.

BadItemLimit (rather than Count, my mistake) goes in like this:


Get-Content YourFile.txt | ForEach-Object {
  Move-Mailbox $_ -TargetDatabase "server\storagegroup\store" -BadItemLimit 100
} | Export-Csv "LogFile.csv"


I believe it returns the status at the end, afraid I can't check.

If the move fails it should simply leave it as is, but please test because I may be mistaken, I don't use this process often.

Chris
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

Author

Commented:
Can i use this with samaccount?
Import-Csv "SomeFile.csv" | ForEach-Object {
  Move-Mailbox $_.SamAccountName -TargetDatabase "server\storagegroup\store" -BadItemLimit 100
} | Export-Csv "LogFile.csv"
Chris DentPowerShell Developer
Top Expert 2010

Commented:

Yep, that should be fine. SamAccountName will provide a unique match.

Chris

Author

Commented:
San i have the ntlogins in the csv in colum A?
Chris DentPowerShell Developer
Top Expert 2010

Commented:

In the example above it doesn't matter which column it's in. Import-CSV loads the CSV into an object with named properties, so $_.SamAccountName will refer to that column regardless of order.

Chris
Chris DentPowerShell Developer
Top Expert 2010

Commented:

Or did you mean in the output?

Chris

Author

Commented:
Thanks its a txt file missed that
I get a prompt with Yes\No
PowerShell Developer
Top Expert 2010
Commented:

> Thanks its a txt file missed that

The output file (LogFile.csv)?

This should suppress the confirmation prompt:


Import-Csv "SomeFile.csv" | ForEach-Object {
  Move-Mailbox $_.SamAccountName -TargetDatabase "server\storagegroup\store" -BadItemLimit 100 -Confirm:$False
} | Export-Csv "LogFile.csv"


Chris

Author

Commented:
Thanks a lot Chris...
                           ... Lots of help today :-)
Chris DentPowerShell Developer
Top Expert 2010

Commented:

No worries :)

Chris

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial