Move Mailbox

Export Users

 

get-mailbox -organizationalunit domain.com/Resources/Users"| Select database, @{Name='alias';Expression={[string]::join(";", ($_.alias))}} | Export-CSV mailboxmove.csv

 

Output file

#TYPE System.Management.Automation.PSCustomObject

 

Database

alias

EX03MB1\First Storage Group\Mailbox Store (EX03MB1)

eford

CLTEX07MB02\First Storage Group\Mailbox Database

afox

EX07MB1\Second Storage Group\First Database

narmstrong

EX03MB1\Second Storage Group\First Database

omoreland

EX03MB1\Second Storage Group\First Database

axpojr

EX03MB1\First Storage Group\Mailbox Store (EX03MB1)

jexpo

EX03MB1\Second Storage Group\First Database

expo-East

EX07MB1\Second Storage Group\First Database

awhite

EX07MB1\Second Storage Group\First Database

bwhite

EX03MB1\Second Storage Group\First Database

ajohnson

EX03MB1\Second Storage Group\First Database

bjohnson

EX03MB1\Second Storage Group\First Database

cjohnson

EX03MB1\First Storage Group\Mailbox Store (EX03MB1)

aford

EX03MB1\First Storage Group\Mailbox Store (EX03MB1)

dford

 

 

 

Script

$Logfile = "c:\mailboxmovelogfile.txt"

$GC = "DC Name"

$error.Clear()

$mailboxuserfile = import-csv c:\users.csv

foreach ($mailboxuser in $mailboxuserfile)

{

$alias = $mailboxuser.alias

$Targetdatabase = $mailboxuser.Targetdatabase

$message = "moving user -> " + $alias

$date = get-date

write-output $date $message | out-file -filepath $Logfile -append -noclobber

move-mailbox -id $alias -targetdatabase $Targetdatabase -globalcatalog $gc -confirm:$false

if($error.count -ne 0)

{

$message = "moving user -> " + $alias + "move failed"

write-output $date $message | out-file -filepath $Logfile -append -noclobber

$message = "Error: " + $error[0].ToString()

write-output $date $message | out-file -filepath $Logfile -append -noclobber

$error.Clear()

}

}

 

CSV file

alias,Targetdatabase
awhite,EX07MB1\first storage group\mailbox database
bwhite,EX07MB1\first storage group\mailbox database

 

Log File output....now we can add more information like statusmessage

Monday, November 09, 2009 11:00:34 PM
moving user ->  awhite

 

Monday, November 09, 2009 11:01:03 PM
moving user ->  bwhite

 

 

 

XML file by default C:\Program Files\Microsoft\Exchange Server\Logging\MigrationLogs

 

[11/9/2009 11:01:03 PM] [0] Executing Command: 'move-mailbox -id $alias -targetdatabase $Targetdatabase -globalcatalog $gc -confirm:$false'
[11/9/2009 11:01:03 PM] [0] Searching objects "EX07MB1\Second Storage Group\First Database" of type "MailboxDatabase" under the root "$null".
[11/9/2009 11:01:03 PM] [0] Previous operation run on domain controller 'DC2.domain.com'.
[11/9/2009 11:01:03 PM] [0] Searching objects "bwhite" of type "ADUser" under the root "$null".
[11/9/2009 11:01:03 PM] [0] Previous operation run on global catalog server 'DC2.domain.com'.
[11/9/2009 11:01:03 PM] [0] Processing object "domain.com/Resources/Users/Berry White".
[11/9/2009 11:01:03 PM] [0] Searching objects "EX03MB1" of type "Server" under the root "$null".
[11/9/2009 11:01:03 PM] [0] Previous operation run on domain controller 'DC2.domain.com'.
[11/9/2009 11:01:03 PM] [0] Searching objects "EX03MB1\First Storage Group\Mailbox Store (EX03MB1)" of type "MailboxDatabase" under the root "$null".
[11/9/2009 11:01:03 PM] [0] Previous operation run on domain controller 'DC2.domain.com'.
[11/9/2009 11:01:03 PM] [0] Ending processing.
[11/9/2009 11:01:03 PM] [0] [bwhite] The operation has started.
[11/9/2009 11:01:03 PM] [0] [bwhite] Approving object.
[11/9/2009 11:01:03 PM] [0] [bwhite] Trying to open mailbox:
 szServerLegacyDN: /o=First Organization/ou=First Administrative Group/cn=Configuration/cn=Servers/cn=EX03MB1
 szUserLegacyDN: /o=First Organization/ou=First Administrative Group/cn=Recipients/cn=bwhite
 szServer: EX03MB1.domain.com
[11/9/2009 11:01:03 PM] [0] [bwhite] Open mailbox succeeded.
[11/9/2009 11:01:04 PM] [0] [bwhite] The operation has finished.
[11/9/2009 11:01:04 PM] [0] Searching objects "domain.com/Resources/Users/Berry White" of type "ADUser" under the root "$null".
[11/9/2009 11:01:04 PM] [0] Previous operation run on global catalog server 'DC2.domain.com'.
[11/9/2009 11:01:04 PM] [0] [bwhite] The operation has started.
[11/9/2009 11:01:04 PM] [0] [bwhite] Approving object.
[11/9/2009 11:01:04 PM] [0] [bwhite] Opening source mailbox.
[11/9/2009 11:01:04 PM] [0] [bwhite] Trying to open mailbox:
 szServerLegacyDN: /o=First Organization/ou=First Administrative Group/cn=Configuration/cn=Servers/cn=EX03MB1
 szUserLegacyDN: /o=First Organization/ou=First Administrative Group/cn=Recipients/cn=bwhite
 szServer: EX03MB1.domain.com
[11/9/2009 11:01:04 PM] [0] [bwhite] Open mailbox succeeded.
[11/9/2009 11:01:04 PM] [0] [bwhite] Trying to lock mailbox:
 szServer: EX03MB1.domain.com
 pguidMdb: {36DFBEEB-51B2-4F88-90AC-7D7BF63DA4F0}
 pguidMailbox: {ACECF3F4-8464-4914-90CA-B3D3A32739C5}
[11/9/2009 11:01:14 PM] [0] [bwhite] Mailbox was locked successfully.
[11/9/2009 11:01:14 PM] [0] [bwhite] Preparing mailbox to be moved.
[11/9/2009 11:01:14 PM] [0] [bwhite] Copying basic mailbox information from source mailbox:
 szServerSrc: EX03MB1.domain.com
 szServerDest: EX07MB1.domain.com
 pguidMdbSrc: {36DFBEEB-51B2-4F88-90AC-7D7BF63DA4F0}
 pguidMdbDest: {A6ED16F4-3796-4A7E-A4C9-0685F4FD6F95}
 pguidMailbox: {ACECF3F4-8464-4914-90CA-B3D3A32739C5}
[11/9/2009 11:01:14 PM] [0] [bwhite] Basic mailbox information was copied successfully.
[11/9/2009 11:01:14 PM] [0] [bwhite] Opening destination mailbox.
[11/9/2009 11:01:14 PM] [0] [bwhite] Trying to open mailbox:
 szServerLegacyDN: /o=First Organization/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=EX07MB1
 szUserLegacyDN: /o=First Organization/ou=First Administrative Group/cn=Recipients/cn=bwhite
 szServer: EX07MB1.domain.com
[11/9/2009 11:01:14 PM] [0] [bwhite] Open mailbox succeeded.
[11/9/2009 11:01:14 PM] [0] [bwhite] Trying to lock mailbox:
 szServer: EX07MB1.domain.com
 pguidMdb: {A6ED16F4-3796-4A7E-A4C9-0685F4FD6F95}
 pguidMailbox: {ACECF3F4-8464-4914-90CA-B3D3A32739C5}
[11/9/2009 11:01:24 PM] [0] [bwhite] Mailbox was locked successfully.
[11/9/2009 11:01:24 PM] [0] [bwhite] Moving messages.
[11/9/2009 11:01:25 PM] [0] [bwhite] 0 items could not be moved to the target mailbox.
[11/9/2009 11:01:25 PM] [0] [bwhite] Updating attributes.
[11/9/2009 11:01:25 PM] [0] [bwhite] Messages moved. Closing connections.
[11/9/2009 11:01:25 PM] [0] [bwhite] Trying to unlock mailbox:
 szServer: EX07MB1.domain.com
 pguidMdb: {A6ED16F4-3796-4A7E-A4C9-0685F4FD6F95}
 pguidMailbox: {ACECF3F4-8464-4914-90CA-B3D3A32739C5}
[11/9/2009 11:01:25 PM] [0] [bwhite] Mailbox was unlocked successfully.
[11/9/2009 11:01:25 PM] [0] [bwhite] Deleting mailbox from mailbox database:
 szServer: EX03MB1.domain.com
 pguidMdb: {36DFBEEB-51B2-4F88-90AC-7D7BF63DA4F0}
 pguidMailbox: {ACECF3F4-8464-4914-90CA-B3D3A32739C5}
[11/9/2009 11:01:25 PM] [0] [bwhite] Mailbox '{ACECF3F4-8464-4914-90CA-B3D3A32739C5}' was deleted successfully.
[11/9/2009 11:01:25 PM] [0] [bwhite] The operation has finished.
[11/9/2009 11:01:25 PM] [0] Searching objects "domain.com/Resources/Users/Berry White" of type "ADUser" under the root "$null".
[11/9/2009 11:01:25 PM] [0] Previous operation run on domain controller 'DC1.domain.com'.
[11/9/2009 11:01:25 PM] [0] Setting Exchange version "0.1 (8.0.535.0)" on object "domain.com/Resources/Users/Berry White".
[11/9/2009 11:01:25 PM] [0] Searching objects "EX07MB1.domain.com" of type "Server" under the root "$null".
[11/9/2009 11:01:25 PM] [0] Previous operation run on domain controller 'DC2.domain.com'.
[11/9/2009 11:01:25 PM] [0] [bwhite] Before applying RUS, the proxy addresses are:
 smtp:bwhite@domain.com
 X400:C=US;A= ;P=First Organizati;O=Exchange;S=White;G=Berry;
 SMTP:White.Berry@domain.com
[11/9/2009 11:01:25 PM] [0] Applying RUS policy to the given recipient "domain.com/Resources/Users/Berry White" with the home domain controller "DC1.domain.com".
[11/9/2009 11:01:25 PM] [0] The RUS server that will apply policies on the specified recipient is "EX07MB1.domain.com".
[11/9/2009 11:01:25 PM] [0] [bwhite] After applying Address List Service, the proxy addresses are:
 smtp:bwhite@domain.com
 X400:C=US;A= ;P=First Organizati;O=Exchange;S=White;G=Berry;
 SMTP:White.Berry@domain.com
[11/9/2009 11:01:25 PM] [0] Setting Exchange version "0.1 (8.0.535.0)" on object "domain.com/Resources/Users/Berry White".
[11/9/2009 11:01:25 PM] [0] Saving object "domain.com/Resources/Users/Berry White" of type "ADUser" and state "Changed".

Powered by BlogEngine.NET 1.5.0.7 | Log in

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar