Set-OctopusVariable not working on PreDeploy.ps1

Set-OctopusVariable -Name ‘WindowsServiceDescription’ -Value ‘This a test from TeamCity’

Write-Host “WS-A:” $OctopusParameters[‘WindowsServiceDescription’]
Write-Host “WS-B:” $WindowsServiceDescription

Set-OctopusVariable -Name “Test” -Value "World!"
Write-Host “TE-A:” $OctopusParameters[‘Test’]
Write-Host “TE-B:” $Test

Hi Marko,

You are right; Set-OctopusVariable is used to set variables that can be used in later PowerShell steps. For example:


Set-OctopusVariable -Name 'Foo' -Value "Bar"


$Foo    # equals "Bar"

But within the same script, you’re right, it doesn’t override the value. For that you could just assign the value to the variable directly. Hope that helps!