Octopus variable doesn't seem to be available in powershell step

We’re trying to include the variable Octopus.Environment.Name in a powershell script that creates a file.

if we reference the variable directly like so .. /tf:"D:\EXTRACTS\${Octopus.Environment.Name}_Logging.dacpac"

The variable shows as being populated if we enable OctopusPrintVariables it looks like it’s got a valid value but it doesn’t carry into our powershell commands,

As a work-around I’ve created a project wide variable called EnvironmentPrefix with a value of #{Octopus.Environment.Name}
And it works fine…

Just thought I’d let you know… (assuming it’s not something we’re doing wrong?)

Cheers,
Graeme.

Hi Graeme,

You can use either:

$OctopusEnvironmentName

Or:

$OctopusParameters["Octopus.Environment.Name"]

We don’t currently pass variables using the ${…} syntax into PowerShell.

Paul

It seems like variable isn’t translated in the powershell. Would you help me out?

  • run
    e:\project_ssis\Install-ISProject.ps1 -IspacFullName e:\project_ssis\octopus"$OctopusParameters[“Octopus.Environment.Name”].ispac

  • outout
    e:\project_ssis\Install-ISProject.ps1 <<<< -IspacFullName e:\project_ssis\oc
    topus"$OctopusParameters[“Octopus.Environment.Name”].ispac"

for us the ${OctopusEnvironmentName} syntax worked.

Strange eh!

Graeme.