Octopus env variable for PowerShell scripts?

Is there an environment variable a PowerShell script could use to detect if it’s being executed from within Octopus?

Hi @cgarcia!

Thanks for reaching out, and for the great question.

We do have a few PowerShell variables you could leverage in this scenario - the easiest of which is probably $OctopusParameters. Another option here is to use the Get-Variable commandlet inside a Run a script step in Octopus to see if there’s something else that could be more fitting.

I hope this helps!

1 Like

ok thanks. I see if I can use some of these variables.

||Line 24: 14:54:59 Info | Name : envOctopusCalamariWorkingDirectory|
||Line 83: 14:54:59 Info | Name : OctopusActionScriptScriptBody|
||Line 84: 14:54:59 Info | Name : OctopusActionScriptScriptFileName|
||Line 85: 14:54:59 Info | Name : OctopusActionScriptSyntax|
||Line 86: 14:54:59 Info | Name : OctopusKey|
||Line 87: 14:54:59 Info | Name : OctopusMachineCommunicationStyle|
||Line 88: 14:54:59 Info | Name : OctopusMachineDeploymentTargetType|
||Line 89: 14:54:59 Info | Name : OctopusMachineHostname|
||Line 90: 14:54:59 Info | Name : OctopusMachineId|
||Line 91: 14:54:59 Info | Name : OctopusMachineName|
||Line 92: 14:54:59 Info | Name : OctopusMachineRoles|
||Line 93: 14:54:59 Info | Name : OctopusParameters|
||Line 94: 14:54:59 Info | Name : OctopusProxy|
||Line 95: 14:54:59 Info | Name : OctopusTentacleAgentApplicationDirectoryPath|
||Line 96: 14:54:59 Info | Name : OctopusTentacleAgentInstanceName|
||Line 97: 14:54:59 Info | Name : OctopusTentacleAgentProgramDirectoryPath|
||Line 98: 14:54:59 Info | Name : OctopusTentacleCurrentDeploymentTargetedRoles|

1 Like