Unable to read Octopus variables from Poweshell scripts

Hi, I have a problem when trying to read Octopus variables from Poweshell scripts PreDeploy.ps1 and Deploy.ps1. I declared two variables ServiceName and OctopusPackageDirectoryPath to be used by PreDeploy.ps1 and Deploy.ps1. It is a windows service which I am trying to deploy to two different environments, and it will have a different name and path for each one. The Poweshell doesn’t read them. Is there something I am missing?
Screenshots and powershell scripts are attached.

Deploy.ps1 (1 KB)

PreDeploy.ps1 (439 Bytes)

an update on this, running the following script on the server doesn’t seem to be working either. OctoService is the default service name

tentacle run-script -f PreDeploy.ps1
Running script…
Service Name: OctoService

Hi Remal,

Can you set a special variable called OctopusPrintEvaluatedVariables to true in your project, and then create and deploy a new release, and attach the deployment log? This will allow me to see whether the variable is correctly set for the deployment script. I notice your ServiceName variables are scoped to a specific machine/steps; perhaps these deploy scripts are being run on a different machine/step? It’s hard to tell from the information provided.