VSTS Quick Tip: PowerShell Task with VSTS Variable Not Working!

If you are at your wits’ end trying to get a specific VSTS variable working inside a PowerShell task and just can’t get it, this quick tip may be helpful to you.

I setup a PowerShell task similar to below and no matter what I did this particular variable would be empty in my PowerShell task.  Other variables worked perfectly fine. 

image

image

Solution

I finally realized the value of this variable started with a dollar sign “$”.  So, PowerShell thought I was referencing a local variable that wasn’t yet defined.  The fix was to wrap the variable in single ticks and assign to a local variable first.

image

image

image

If this post helped you or you have further suggestions/questions please leave a comment below.

Happy Deploying!

Leave a Reply