Link to home
Start Free TrialLog in
Avatar of API
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¿ -RemoteForestDomainController “OldForest.local” -RemoteForestCredential $RemoteCredentials -LocalDomainController “NewForest.local” -LocalForestCredential $LocalCredentials -TargrtMailUserOU “OU=User Accounts,DC=NewForest,DC=Local -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¿ – <<<<RemoteForestDomainController "OldForest.local" -RemoteForestCredential $RemoteCredentials -LocalDomainController "NewForest.local" -LocalForestCredential $LocalCredentials -TargrtMailUserOU "OU=User Accounts,DC=NewForest,DC=Local -UseLocalObject -OverWriteLocalObject -Verbose
 + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
 + FullyQualifiedErrorId : ExpectedValueExpression
 
Not sure what I'm doing wrong.
Avatar of Rajitha Chimmani
Rajitha Chimmani
Flag of United States of America image

You are missing the -Identity parameter which is the required parameter for this script.

Check the section "Parameter set of the script" in the following link

http://technet.microsoft.com/en-us/library/ee861103.aspx
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
}

Open in new window

Avatar of API
API

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 -RemoteForestDomainController OldForest.local -LocalDomainController NewForest.local -LocalForestCredential
$LocalCredentials -TargrtMailUserOU ",OU=User Accounts,DC=NewForest,DC=Local -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=Local -UseLocalObject -OverWriteLocalObject -Verbose
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + 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):
. .\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

Open in new window


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

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of API
API

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
Avatar of API

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.