I am stuck on what I feel is pretty simple. I have a secret string I created under automation/variables called ‘pass’
later in the script im trying to pass $password as a variable to another command.
$password = Get-UAVariable -Name 'pass'
$PostRequest = "grant_type=password" +
Write-host "Params: $PostRequest "
$wc = New-Object System.Net.WebClient
$wc.UploadString("redacted", $PostRequest ) | ConvertFrom-Json
Is this not the intention of variables?
Currently running v2 but tested on version 1.5.14 as well
You can just use the variable directly. Get-UAVariable is return the reference to the variable. For secrets, you won’t be able to access the Value through the Management API (which is what Get-UAVariable uses).
Try changing your script to:
$Password = $Pass
Interesting. I would have never guessed that would work. So all scripts have access to the $VariablesName Is this in the documentation somewhere? I saw this new-uavariable but overlooked that comment.
It’s funny. I went and checked the documentation and there actually wasn’t any information on this.
I have added this section here: Variables - PowerShell Universal
Thanks for getting back so quickly on this. I thought I was going crazy. Keep up the good work.
I tried the same but its not working. Not sure what I’m missing. I even upgraded the UA to latest version 2.2.1. Can you please suggest?
My scripts are unable to read the value of secret variables.
#Not Secret Variable
Aug 11, 2021 9:45 AM [warning] Failed to verify module and server version. Call failed. The SSL connection could not be established, see inner exception. GET https://localhost:443/api/v1/version
Aug 11, 2021 9:45 AM Test
Aug 11, 2021 9:45 AM Test2