Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

PowerShell Prepare-MoveRequest error

Posted on 2013-02-05
6
Medium Priority
?
1,059 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

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

There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
On September 18, Experts Exchange launched the first installment of the Help Bell, a new feature for Premium Members, Team Accounts, and Qualified Experts. The Help Bell will serve as an additional tool to help teams increase question visibility.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.
Suggested Courses

722 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