0

When I try and run this command I keep getting "Missing ')' in method call."

What am I misssing?

powershell -Command "& 
{
 if ((Get-Date -displayHint Time (GetDate)
         .AddMinutes(-15)
         .ToUniversalTime() -format HH:mm:ss) 
-lt ([datetime]::ParseExact('13:38:43', "HH:mm:ss", $null))) 
{ return 0 } 
else { return 1}'}"
1
  • what's with the single quote after the close bracket on return? else { return 1}'}" Commented Jun 13, 2013 at 15:19

2 Answers 2

3

A few things:

  1. If you used outer double quotes to wrap the command, use single quotes inside of it.
  2. You have a typo: GetDate -> Get-Date
  3. You can skip displayHint and get the time part with:

    (Get-Date)AddMinutes(-15).ToUniversalTime() -format 'HH:mm:ss'

  4. I suggest to use the -File parameter and pass a script path when your command is longer than a simple one liner, it can save you some head ache.

Here's the full command:

"&
{
    if((Get-Date -displayHint Time (Get-Date).AddMinutes(-15).ToUniversalTime() -format 'HH:mm:ss')  -lt 
    ([datetime]::ParseExact('13:38:43', 'HH:mm:ss', $null))) 
    {return 0} else { return 1}
}"
Sign up to request clarification or add additional context in comments.

Comments

1

Not sure of what you want to do, but you can try :

 if ((Get-Date -displayHint Time (Get-Date).AddMinutes(-15).ToUniversalTime() -format HH:mm:ss) -lt ([datetime]::ParseExact('13:38:43', "HH:mm:ss", $null)))
 { return 0 } 
 else
 { return 1}

I replace GetDate by Get-Date.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.