API
asked on
PowerShell Prepare-MoveRequest error
I am running the command below from the management shell “as administrator”:
Import-Csv “c:\test\users.txt” | “.\Prepare-MoveRequest.ps1 ¿ -RemoteForestDomainControl ler “OldForest.local” -RemoteForestCredential $RemoteCredentials -LocalDomainController “NewForest.local” -LocalForestCredential $LocalCredentials -TargrtMailUserOU “OU=User Accounts,DC=NewForest,DC=L ocal -UseLocalObject -OverWriteLocalObject -Verbose
I am then receiving the following error:
You must provide a value expression on the right-hand side of the ‘-’ operator.
At line:1 char:63
+ Import-Csv “c:\test\users.txt” | “.\Prepare-MoveRequest.ps1 ¿ – <<<<RemoteForestDomainCont roller "OldForest.local" -RemoteForestCredential $RemoteCredentials -LocalDomainController "NewForest.local" -LocalForestCredential $LocalCredentials -TargrtMailUserOU "OU=User Accounts,DC=NewForest,DC=L ocal -UseLocalObject -OverWriteLocalObject -Verbose
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordE xception
+ FullyQualifiedErrorId : ExpectedValueExpression
Not sure what I'm doing wrong.
Import-Csv “c:\test\users.txt” | “.\Prepare-MoveRequest.ps1
I am then receiving the following error:
You must provide a value expression on the right-hand side of the ‘-’ operator.
At line:1 char:63
+ Import-Csv “c:\test\users.txt” | “.\Prepare-MoveRequest.ps1
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordE
+ FullyQualifiedErrorId : ExpectedValueExpression
Not sure what I'm doing wrong.
You're missing the ForEach-Object cmdlet. Here's your code a bit cleaned up
Import-Csv "c:\test\users.txt" | ForEach-Object {
. .\Prepare-MoveRequest.ps1 -RemoteForestDomainController "OldForest.local" -RemoteForestCredential $RemoteCredentials -LocalDomainController "NewForest.local" -LocalForestCredential $LocalCredentials -TargetMailUserOU "OU=User Accounts,DC=NewForest,DC=Local" -UseLocalObject -OverWriteLocalObject -Verbose
}
ASKER
Thanks for the quick replies but the link you refer to is were I got the script from in the first place. I beleive the include file negates the need for the Identity parameter. I also tried to run the script provided above and receive the same error. I tried running it with a single user with the -identity parameter as below:
".\Prepare-MoveRequest.ps1 " -Identity bbunny@domain.com
-RemoteForestCredential $RemoteCredentials -RemoteForestDomainControl ler OldForest.local -LocalDomainController NewForest.local -LocalForestCredential
$LocalCredentials -TargrtMailUserOU ",OU=User Accounts,DC=NewForest,DC=L ocal -UseLoc
alObject -OverWriteLocalObject -Verbose
You must provide a value expression on the right-hand side of the '-' operator.
At line:1 char:30
+ ".\Prepare-MoveRequest.ps1 " - <<<< Identity bbunny@domain.com -RemoteForestCredential $RemoteCredentials -LocalD
omainController "NewForest.local" -LocalForestCredential $LocalCredentials -TargrtMailUserOU "OU=User Accounts,DC=NewForest,DC=L ocal -UseLocalObject -OverWriteLocalObject -Verbose
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordE xception
+ FullyQualifiedErrorId : ExpectedValueExpression
So what it looks like is any parameter after the script fails.
".\Prepare-MoveRequest.ps1
-RemoteForestCredential $RemoteCredentials -RemoteForestDomainControl
$LocalCredentials -TargrtMailUserOU ",OU=User Accounts,DC=NewForest,DC=L
alObject -OverWriteLocalObject -Verbose
You must provide a value expression on the right-hand side of the '-' operator.
At line:1 char:30
+ ".\Prepare-MoveRequest.ps1
omainController "NewForest.local" -LocalForestCredential $LocalCredentials -TargrtMailUserOU "OU=User Accounts,DC=NewForest,DC=L
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordE
+ FullyQualifiedErrorId : ExpectedValueExpression
So what it looks like is any parameter after the script fails.
I think you might have a couple of typos in your code: 1) there's a comma inside the target OU, and 2) you're missing a closing double quotes
Try this on your single user (assuming you're dot-sourcing):
Same command but visually a bit more helpful:
Try this on your single user (assuming you're dot-sourcing):
. .\Prepare-MoveRequest.ps1 -Identity bbunny@domain.com -RemoteForestCredential $RemoteCredentials -RemoteForestDomainController OldForest.local -LocalDomainController NewForest.local -LocalForestCredential $LocalCredentials -TargrtMailUserOU "OU=User Accounts,DC=NewForest,DC=Local" -UseLocalObject -OverWriteLocalObject -Verbose
Same command but visually a bit more helpful:
. .\Prepare-MoveRequest.ps1 -Identity bbunny@domain.com `
-RemoteForestCredential $RemoteCredentials `
-RemoteForestDomainController OldForest.local `
-LocalDomainController NewForest.local `
-LocalForestCredential $LocalCredentials `
-TargrtMailUserOU "OU=User Accounts,DC=NewForest,DC=Local" `
-UseLocalObject `
-OverWriteLocalObject `
-Verbose
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I found an answer to the issue at another forum and posted it here to assist others in the event they receive the same error.
Check the section "Parameter set of the script" in the following link
http://technet.microsoft.com/en-us/library/ee861103.aspx