Solved

PowerShell Prepare-MoveRequest error

Posted on 2013-02-05
6
1,038 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
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Read this checklist to learn more about the 15 things you should never include in an email signature.
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
This tutorial will show how to configure a single USB drive with a separate folder for each day of the week. This will allow each of the backups to be kept separate preventing the previous day’s backup from being overwritten. The USB drive must be s…

896 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

15 Experts available now in Live!

Get 1:1 Help Now