Step PowerShell Inline Script cannot be executed (fails) although it works correctly in PowerShell

Hi,

I have PowerShell script which executes completely correctly when I run it in powershell from my PowerShell Terminal. But in the Octopus it FAILS (although other scripts for that Deployment Target/Tenant are successful so it is not connections issue)

> $REPORT_PATH = "C:\Projects\FA\report"
> $SCRIPT_PATH= "C:\ProgramData\Packages\script.robot"
> $ADS_SERVER = "SERVER1:9000"
> $ROBOT_PATH="C:\Program Files\Test Framework\Robot Framework\Scripts"
> Write-Host("Running robot script")
& "${ROBOT_PATH}\robot.bat" -d $REPORT_PATH -v adsName:$ADS_SERVER -i Initialize $SCRIPT_PATH

So basically everything is correct until the last CODE line; I put the ampersand sign on purpose because that is how it works in PowerShell but I cannot make it work in Octopus.
I tried several options and I cannot make it work in Octopus. Please assist.

This is the output with error (I cannot find anything useful in this information so I am really not sure why it fails - I will be grateful for assistance - THANKS)

Running robot script

May 26th 2020 19:16:37

Error

Calamari.exe : NotSpecified: Traceback (most recent call last):

May 26th 2020 19:16:37

Error

At C:\Octopus\Work\20200526171634-5939-26\Bootstrap.ps1:38 char:1

May 26th 2020 19:16:37

Error

+ & “${env:TentacleHome}\Calamari\11.1.2\Calamari.exe” run-script -sen …

May 26th 2020 19:16:37

Error

***+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~***

May 26th 2020 19:16:37

Error

+ CategoryInfo : NotSpecified: (NotSpecified: T…ent call last)::String) [], RemoteException

May 26th 2020 19:16:37

Error

+ FullyQualifiedErrorId : NativeCommandError

May 26th 2020 19:16:37

Error

May 26th 2020 19:16:37

Error

At C:\Octopus\Work\20200526171634-5939-26\Script.ps1:44 char:1

May 26th 2020 19:16:37

Error

+ & “${ROBOT_PATH}\robot.bat” -d $REPORT_PATH -v adsName:$ADS_SERVER -i …

May 26th 2020 19:16:37

Error

***+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~***

May 26th 2020 19:16:37

Error

at , C:\Octopus\Work\20200526171634-5939-26\Script.ps1: line 44

May 26th 2020 19:16:37

Error

at , C:\Octopus\Work\20200526171634-5939-26\Bootstrap.Script.ps1: line 1532

May 26th 2020 19:16:37

Error

at , : line 1

May 26th 2020 19:16:37

Error

at , : line 1

May 26th 2020 19:16:37

Fatal

The remote script failed with exit code 1

May 26th 2020 19:16:37

Fatal

The action … failed

Hey @veljkosbbb,

I did a really simple reproduction of your script:

$REPORT_PATH = "C:\Projects\FA\report"
$SCRIPT_PATH= "C:\ProgramData\Packages\script.robot"
$ADS_SERVER = "SERVER1:9000"
$ROBOT_PATH="C:\Temp"
Write-Host("Running robot script")
& "${ROBOT_PATH}\test.bat" $REPORT_PATH $ADS_SERVER $SCRIPT_PATH 

test.bat just echoes the variables I’m passing into a text document. This worked in my reproduction environment. I had a few follow up questions.

Which version of Octopus are you running?

If you run PowerShell as the Octopus Service account locally on the machine, does the script work?

Does it also run in non-interactive mode?

Thanks,
Jeremy

1 Like

Thank you its working now, although I am really not sure what was the issue.
Thanks

1 Like

You’re welcome! Please reach out if it stops working for some reason and we can take a look together.

Have a good rest of your week.

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.