Unable to process password variable in powershell because of special characters RRS feed

  • Question

  • Hi Team, I am working on a PS script to install VSTS agents on my Azure VMs through an Azure DevOps Release Pipeline.

    Here in the below script, I am passing a Service Account Password, which is set by my customers. Below script fails whenever Password consist of special characters like


     .\config.cmd --deploymentgroup --deploymentgroupname DeployGroupSQL --agent $env:COMPUTERNAME


    --windowsLogonAccount $(ServiceAccountUser)

    --windowsLogonPassword "$(Service_Account_Password)" --work '_work'

    --adddeploymentgrouptags --deploymentgrouptags $SQL

    --url 'https://dev.azure.com/campusmgmt-product-development/'

    --projectname 'Student' --auth PAT --token u4bq6j******************************bhhyq; 

    I have tried putting whole password into double quotes as well as single quotes but of no help.

    This Service Account Password is a Pipeline variable and hence needs to be passed like $(Service_Account_Password).

    Can you please suggest on how can I deal with this situation. I have already tried putting this as a here-string, Secure-String, or script parameter but has not proved of any help.

    Hoping to hear back soon as this is urgent for my project release.

    Tuesday, April 2, 2019 6:26 AM

All replies

  • Sorry but that is not a PowerShell command and this is a PowerShell forum.  Please post your issues in the correct forum for VSTS.


    Tuesday, April 2, 2019 8:20 AM
  • May be you are right and this is not exactly a PowerShell command. But eventually this could be only resolved if you know PowerShell.

    I was hoping you guys could help, but no worries. 

    Feel it was my luck day today. After banging my head for past 8 hours on this I could finally work this through using Stop-Script character in PowerShell '--%'.  Which obviously was PowerShell

    Solution I tried:
    .\config.cmd --deploymentgroup --deploymentgroupname DeployGroupCTS --agent $env:COMPUTERNAME --runasservice --work '_work' --adddeploymentgrouptags --deploymentgrouptags $CTS --url 'https://dev.azure.com/campusmgmt-product-development/' --projectname 'Student' --auth PAT --token u4bq6j************************************hhyq --windowsLogonAccount $(ServiceAccountUser) --windowsLogonPassword --% "$(Service_Account_Password)" %;%

    Ref: https://stackoverflow.com/questions/18923315/using-in-powershell

    Hope this might helps others.

    Praharsh Pandey

    Tuesday, April 2, 2019 12:37 PM
  • The issue has nothing to do with PowerShell.  You are running a batch file that addresses a subsystem that is not a PowerShell system.  Post in the correct forum if you actually want to get an answer.

    There is no PowerShell code anywhere in you example.  Just because there is a $ in the line does not make it PowerShell.


    Tuesday, April 2, 2019 3:25 PM