0

I am trying to run powershell command. I have set up 2 variables:

$env:P7_TESTING_INSTALLATION_PATH = "D:\Logos_block_gitlab_runner\pSeven-v2024.05"
$env:CI_PROJECT_DIR = "D:\Logos_block_gitlab_runner\GitLab-Runner\builds\vDLVWCgmH\0\aero\logos_userblock"

Then I am trying to run command using these variables:

Invoke-Command -ScriptBlock {$env:P7_TESTING_INSTALLATION_PATH\client\p7batch.exe --log-level=error --run $env:CI_PROJECT_DIR\autotest\jobs\_clear.py}

But I have got unexpected token error with "\client\p7batch.exe"...

2
  • 1
    & $env:P7_TESTING_INSTALLATION_PATH\client\p7batch.exe ... also $using: instead of $env: Commented Jun 25, 2024 at 12:33
  • In short: An executable path that is quoted or contains variable references must - for syntactic reasons - be invoked with &, the call operator; see the linked duplicate for details. Commented Jun 25, 2024 at 16:54

1 Answer 1

2

No matter what, you need the call operator to run something partially in a variable. Invoke-command isn't needed. Environment variables aren't needed.

& $P7_TESTING_INSTALLATION_PATH\client\p7batch.exe --log-level=error `
  --run $CI_PROJECT_DIR\autotest\jobs\_clear.py
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.