Custom PowerShell Script issues with variables which specify an application to run

We are using the new custom powershell feature and have noticed an issue with it. We currently use this feature to run a command line application we have installed on our servers. The path to this application is stored in a library variable. If I specify the following it will generate an error:

Code:
write-host "Run Custom App"
write-host $OctopusParameters[‘ApplicationPath’]

$OctopusParameters[‘ApplicationPath’] /en /f:.\Web.config /s:connectionStrings /force

Error:
You must provide a value expression on the right-hand side of the ‘/’ operator.
At \CustomScriptConvention.PostDeploy.ps1:4 char:63

  • $OctopusParameters[‘ApplicationPath’] / <<<< en /f:.\Web.config /s:connectionStrings /force
    • CategoryInfo : ParserError: (:slight_smile: [], ParentContainsErrorRecordException
    • FullyQualifiedErrorId : ExpectedValueExpression
      Fatal 10:27:44
      PowerShell script returned a non-zero exit code: 1

However if we hard code the path then everything works fine. It looks as though the parser you are using is not interpreting the octopus variable correctly when evaluating the power-shell statement.

HI Matthew,

We just rung PowerShell.exe on the script file, so behaviour should be consistent if you run this in ISE.

I believe the required syntax for this is something like:

& "$OctopusParameters['ApplicationPath']" /en /f:.\Web.config /s:connectionStrings /force

… but it always seems to take a little trial-and-error for me to get this right :slight_smile:

Cheers,
Nick