title: Correct way to use secret variable in PowerShell script
body: <p>What is the correct way to use a secret variable in a PowerShell script? It may be a pipeline variable, a variable group one, or a variable brought in from an Azure Key Vault task.
  I have seen in the documentation that it cannot be used in the same way as a normal (non-secret) variable. It says "Instead, we suggest that you map your secrets into environment variables." and "You need to explicitly map secret variables."
  I have used an environment variable and it works. Are there other ways to do it? <a href="https://zimmergren.net/using-azure-key-vault-secrets-from-azure-devops-pipeline/" rel="noreferrer">This blog</a> says you can use it directly in the script, which seems to contradict the MS document. 
  <a href="https://www.azuredevopslabs.com/labs/vstsextend/azurekeyvault/" rel="noreferrer">This one</a> passes the variable as an argument or parameter to the scripts. Does anyone know what is actually going on behind the scenes?</p>