Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Escaping double dollar signs in password in AZ CLI in PowerShell shell

I'm trying to run the az sql db export command and it requires a SQL Admin username and password. Our password happens to have two dollar signs in it e.g. ABC$$123==). So when I run the following command (with valid values in it, of course):

$pwd = "ABC$$123==)"
az sql db export -s myserver -n mydatabase -g mygroup -p $pwd-u login \
    --storage-key MYKEY== --storage-key-type StorageAccessKey \
    --storage-uri https://myAccountName.blob.core.windows.net/myContainer/myBacpac.bacpac

I get this response:

')' is not recognized as an internal or external command,
operable program or batch file.

I've tried so many variations of escaping this but haven't found the correct method that works. In the end, I plan to read the password from Azure Key Vault and was gonna pass it straight in to the az cli command. What do I have to do to get this to work?

like image 877
beaudetious Avatar asked Oct 28 '25 05:10

beaudetious


1 Answers

There are two types of quotes in powershell - single and double. In the double quote, you can pass in variables. In a single quote, everything is literal. For cases like your password, I would recommend just using the literal:

$pwd = 'ABC$$123==)'
like image 143
V3rmouth Avatar answered Oct 31 '25 04:10

V3rmouth