Link to home
Start Free TrialLog in
Avatar of vhaperbaugub
vhaperbaugub

asked on

Exchange Power Shell Scripts

Hello - I need to have the following Exchange Power Shell Scripts:
1. To move a mailbox from one Exchange 2007 database to another.
2. To disconnect a mailbox from a user.
3. To connect a mailbox to a user.

Thanks
Avatar of endital1097
endital1097
Flag of United States of America image

move-mailbox user -targetdatabase server\sg\db
disable-mailbox user
enable-mailbox user
enable-mailbox cmdlet (2010 link but same as 2007)
http://technet.microsoft.com/en-us/library/aa998251.aspx

Avatar of Akhater
1. move-mailbox UserName -database SourceDatabase -TargetDatabase TargetDatabase

2. disable-mailbox username

3. when you say connect you mean create a new mailbox ?
enable-mailbox username -database DatabaseName
Avatar of vhaperbaugub
vhaperbaugub

ASKER

What I'm saying is for example a user moves from Chicago to Cleveland, the user will still be with the same company and he also wants to keep his old email. However, he will not be on the same Exchange Server\Database, and Cleveland has a different login username than Chicago. What PowerShell Scripts would I use to disconnect the user from his mailbox in Chicago, move the mail to Cleveland, and then reconnect him to the mail in Cleveland with his new username?
if it is still the same user there is no reason why his username will change from one site to another.

In all cases you cannot "move" a disconnected mailbox
this will disable the mailbox from the current account
disable-mailbox chicago

then you reconnect
Connect-Mailbox -Identity chicago -Database "Mailbox Database" -User cleveland
http://technet.microsoft.com/en-us/library/bb201701(EXCHG.80).aspx
however the issue you have there is the mailbox still resides in chicago
you would then want to run the move-mailbox cmdlet
The organization that I work with changes the username to match the location that the user is at. If not move, can it be copied from one location to another and then deleted?
i would just rename the useraccount and move the mailbox
since they are on the same server just different databases it would be

move-mailbox olduser -database newdb
disable-mailbox olduser
connect-mailbox olduser -user newuser

however, if my memory serves me right, you cannot connect the mailbox of a user to another user as long as the original user exists so you should replace the disable-mailbox by remove-mailbox which will delete the account from AD
"i would just rename the useraccount and move the mailbox"

seconded !
Renaming the user account will work if they are located in the same Domain, but what would I need to do if they were not.
ASKER CERTIFIED SOLUTION
Avatar of Akhater
Akhater
Flag of Lebanon 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
then you need to create the new account, disable the current mailbox, and connect the new account to the mailbox, move the mailbox

commands given earlier
good call, forgot about that tool