Solved

PowerShell Prepare-MoveRequest error

Posted on 2013-02-05
6
1,035 Views
Last Modified: 2013-02-13
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.
0
Comment
Question by:API
  • 3
  • 2
6 Comments
 
LVL 16

Expert Comment

by:Rajitha Chimmani
ID: 38857671
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
0
 
LVL 5

Expert Comment

by:coraxal
ID: 38857681
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

0
 

Author Comment

by:API
ID: 38857854
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.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 5

Expert Comment

by:coraxal
ID: 38857993
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

0
 

Accepted Solution

by:
API earned 0 total points
ID: 38861117
The typos were not in the command that's from me editing the code to to remove my domain info.

I was able to get this to work finally with the below command:

Import-Csv users.csv | &".\Prepare-MoveRequest.ps1" -RemoteForestDomainController "OldForest.local" -RemoteForestCredential $RemoteCredentials -LocalDomainController "NewForest.local" -LocalForestCredential $LocalCredentials -TargetMailUserOU "OU=User Accounts,DC=NewForest,DC=Local" -UseLocalObject -OverWriteLocalObject -Verbose

There was no mention to the & before the script in the technet article.
0
 

Author Closing Comment

by:API
ID: 38883792
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.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now