[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1201
  • Last Modified:

Powershell error

I keep getting this error:

PowerCLI C:\> "test.ps1" -AfterDate 08/21/2012 -FileName C:\Report.txt
You must provide a value expression on the right-hand side of the '-' operator.
At line:1 char:13
+ "test.ps1" - <<<< AfterDate 08/21/2012 -FileName C:\Report.txt
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordEx
   ception
    + FullyQualifiedErrorId : ExpectedValueExpression

I've changed the date several times. I'm assuming this is realated to the format of the date but I can't seem to get it to work.
0
xmouser
Asked:
xmouser
2 Solutions
 
dicconbCommented:
Try taking the quotes out from around script filename.

Cheers,

D
0
 
xmouserAuthor Commented:
That's how I started:

Suggestion [3,General]: The command test.ps1 was not found, but does exist in th
e current location. Windows PowerShell doesn't load commands from the current lo
cation by default. If you trust this command, instead type ".\test.ps1". See "ge
t-help about_Command_Precedence" for more details.

That's why I put the quotes around it.

Also tried it with ".\test.ps1"
0
 
pony10usCommented:
If I read (and count) it correctly it has to do with the "/" in the date.
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
xmouserAuthor Commented:
The script as posted at MS has it in the format that I'm using. There the example was 09/09/09. How should it be?
0
 
dicconbCommented:
Try .\test.ps1 with no quotes, ie:
.\test.ps1 -AfterDate 08/21/2012 -FileName C:\Report.txt

Open in new window

If quotes are required (eg if there are spaces in the file name), put an ampsersand in front, ie:
& ".\test.ps1" -AfterDate 08/21/2012 -FileName C:\Report.txt

Open in new window


The reason for the original error is that powershell is interpreting "test.ps1" as a string rather than the name of a script that it should execute.

Cheers,

D
0
 
xmouserAuthor Commented:
I'm getting this:


PowerCLI C:\> & ".\test.ps1" -AfterDate 08/21/2012 -FileName C:\Report.txt
Missing closing ')' in expression.
At C:\test.ps1:40 char:12
+             <<<< [String]
    + CategoryInfo          : ParserError: (CloseParenToken:TokenId) [], Parse
   Exception
    + FullyQualifiedErrorId : MissingEndParenthesisInExpression
0
 
slidingfoxCommented:
Looks like your missing an ')' around line 40 of your script.
0
 
dicconbCommented:
Thanks for the points,

D
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now