happyexchange
asked on
moving users from one storage group to another in exchange 2007
Hi ive been trying to move users (please see attachment) from one storage group to another using the script below.
$users = Import-Csv sheeta.csv -Header (gc sheeta.csv)[0].trim(",").s plit(",") | select -skip 1
foreach ($user in $users) {move-mailbox $user.DisplayName -targetDatabase $user.targetdatabase}
I kept getting this error message. Am i doing something wrong with the script. Thank you all. Im running it in the exchange console
PS] C:\Documents and Settings\admin.jamiec>$use rs = Import-Csv dat03.csv -Head
er (gc sheeta.csv)[0].trim(",").s plit(",") | select -skip 1
Get-Content : Cannot find path 'C:\Documents and Settings\admin.jamiec\shee ta.c
sv' because it does not exist.
At line:1 char:43
+ $users = Import-Csv dat03.csv -Header (gc <<<< sheeta.csv)[0].trim(",").s pl
it(",") | select -skip 1
+ CategoryInfo : ObjectNotFound: (C:\Documents an...miec\sheeta.c
sv:String) [Get-Content], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.Pow erShell.Co mmands.Get Co
ntentCommand
Cannot index into a null array.
At line:1 char:56
+ $users = Import-Csv dat03.csv -Header (gc sheeta.csv)[ <<<< 0].trim(",").spl
it(",") | select -skip 1
+ CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
[PS] C:\Documents and Settings\admin.jamiec>fore ach ($user in $users) {move-mail
box $user.DisplayName -targetDatabase $user.targetdatabase}
Move-Mailbox : Cannot bind argument to parameter 'TargetDatabase' because it is
null.
At line:1 char:74
+ foreach ($user in $users) {move-mailbox $user.DisplayName -targetDatabase <<<
< $user.targetdatabase}
+ CategoryInfo : InvalidData: (:) [Move-Mailbox], ParameterBindin
gValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidatio nErrorNull NotAllowed ,M
icrosoft.Exchange.Manageme nt.Recipie ntTasks.Mo veMailbox
dat03-csv-1-.xls
$users = Import-Csv sheeta.csv -Header (gc sheeta.csv)[0].trim(",").s
foreach ($user in $users) {move-mailbox $user.DisplayName -targetDatabase $user.targetdatabase}
I kept getting this error message. Am i doing something wrong with the script. Thank you all. Im running it in the exchange console
PS] C:\Documents and Settings\admin.jamiec>$use
er (gc sheeta.csv)[0].trim(",").s
Get-Content : Cannot find path 'C:\Documents and Settings\admin.jamiec\shee
sv' because it does not exist.
At line:1 char:43
+ $users = Import-Csv dat03.csv -Header (gc <<<< sheeta.csv)[0].trim(",").s
it(",") | select -skip 1
+ CategoryInfo : ObjectNotFound: (C:\Documents an...miec\sheeta.c
sv:String) [Get-Content], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.Pow
ntentCommand
Cannot index into a null array.
At line:1 char:56
+ $users = Import-Csv dat03.csv -Header (gc sheeta.csv)[ <<<< 0].trim(",").spl
it(",") | select -skip 1
+ CategoryInfo : InvalidOperation: (0:Int32) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
[PS] C:\Documents and Settings\admin.jamiec>fore
box $user.DisplayName -targetDatabase $user.targetdatabase}
Move-Mailbox : Cannot bind argument to parameter 'TargetDatabase' because it is
null.
At line:1 char:74
+ foreach ($user in $users) {move-mailbox $user.DisplayName -targetDatabase <<<
< $user.targetdatabase}
+ CategoryInfo : InvalidData: (:) [Move-Mailbox], ParameterBindin
gValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidatio
icrosoft.Exchange.Manageme
dat03-csv-1-.xls
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No, leave '$users = ' there, but extend the path to full path.
ASKER
Sorry mate.
So c:\documentsand settings\adminjamiec
But when i open the exchange cmdlet that is aleady there. it starts with C:\documentsand settings\adminjamiec\ then i put the script in.
So c:\documentsand settings\adminjamiec
But when i open the exchange cmdlet that is aleady there. it starts with C:\documentsand settings\adminjamiec\ then i put the script in.
Sorry, the the path is missing from here also:
(gc sheeta.csv)
Anyway, the file should be edited a bit: the empty lines should be deleted, and the one with some summary data in it should also be deleted.
And I also recommend to fill in all the headers in each column. If you do this, you can simplify the import to:
$users = Import-Csv c:\yourfile\sheeta.csv
(gc sheeta.csv)
Anyway, the file should be edited a bit: the empty lines should be deleted, and the one with some summary data in it should also be deleted.
And I also recommend to fill in all the headers in each column. If you do this, you can simplify the import to:
$users = Import-Csv c:\yourfile\sheeta.csv
ASKER
I have split the spreadsheet into 3 called dat01 + dat02 + dat03 and deleted any lines.
Sorry mate could you write the script so i would know what it is and do.
Thank you for everything
Sorry mate could you write the script so i would know what it is and do.
Thank you for everything
If you have 3 CSV files, no emptly lines, no summary, but a column header for every columns that have values and for all columns that are between columns that have values, then you can do the following:
$users = @(Import-Csv c:\yourpath\sheeta.csv) + @(Import-Csv c:\yourpath\sheetb.csv) +@(Import-Csv c:\yourpath\sheetc.csv)
foreach ($user in $users) {move-mailbox $user.DisplayName -targetDatabase $user.targetdatabase}
$users = @(Import-Csv c:\yourpath\sheeta.csv) + @(Import-Csv c:\yourpath\sheetb.csv) +@(Import-Csv c:\yourpath\sheetc.csv)
foreach ($user in $users) {move-mailbox $user.DisplayName -targetDatabase $user.targetdatabase}
ASKER
The csv file is saved as dat03.csv in my admin profile on the exchange. Does that matter