Scoped project variables are not accessible in powershell


I have a project variable defined with scope as below screenshot and accessing this variable in PowerShell script statement “Write-Output 2 ${SmtpAddress}” but it is always empty. It prints the value only if the scope is removed from the project variable. But I have to specify the scope for different environments having different values. Please help me if the syntax is wrong or is there another way to access scoped project variables in powershell.


Hi @11nandini94,

Thanks for reaching out and posting your question, and sorry to hear you’re experiencing that issue.

I was wondering if you could share what the scoping for your deployment targets associated with your example ‘SharePoint 2019 Dev’ environment looks like? A screenshot would be perfect. I’m thinking there might be some scoping at the target level causing this, so it’s a good start to check there.

Looking forward to hearing back from you!


Hi @patrick.smergut

Thank you, so much for the directions to check the issue. I was similar names (SharePoint 2019 Dev and another SharePointAppDev19) for my environments and was choosing the wrong one for the scope.
After specifying the right environment scope, It worked perfectly!


Hi @11nandini94,

Thanks for the additional information. I can’t see anything unusual there.

In the project where you’re running your Powershell script, is that deployment targeting the SharePoint 2019 Dev environment?

One option that may help you troubleshoot this would be to add the system variable OctopusPrintEvaluatedVariables to your project with a value of true. This will then print out all variables to the task log and allow you to see what values are being defined.

Judging from your configuration, the only way I can see the variable not appearing during a deployment would be if the deployment was being made to a different environment, such as SharePoint2019AppDev or SharePoint2019AppDEVx2


This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.