Solved

PowerShell Prepare-MoveRequest error

Posted on 2013-02-05
6
1,042 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 
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

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

Suggested Solutions

Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

730 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