I am building a project server solution with azure devops.
In my release pipeline I have multiple powershell scripts that requre user credentials as parameters. The password is saved in a secret variable in DevOps and contains a single quote.
Password: abcd'efgh
This leads to the pipeline throwing an error: "The string is missing the terminator: '."
When I hard code the password into the pipeline with double quotes the script executes perfectly.
Argument: -password "abcd'efgh"
When I put the DevOps secret variable in double quotes the script executes, but gives me an error when trying to authenticate at the server, possible because the password that is passed is "***".
Argument: -password "$(passwordVariable)"
Here is the relevant part of the script that is being executed by the pipeline. Any help is greatly appreciated.
param(
$siteUrl,
$username,
$password
)
$encpassword = convertto-securestring -String $password -Force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
Connect-PnPOnline -Url $siteUrl -Credentials $cred
How do I get the password into the script?
@
symbol."[email protected]"
is converted to"***"
. If I remove domain info, it is fine,"myname"
remains"myname"
. – Mike Williamson