Within a script, how do I reference a secret variable that I had defined in the Variables section of PS Universal? Sorry if this is a stupid question but I cannot find this in any documentation, or after much Googling.
I’m trying to securely look up passwords and API tokens within scripts for Invoke-RestMethod, if there’s a better way to do that than defining them as secret variables I’d love to hear it.
Are you trying to use the secrets in your jobs\scripts? If so, you can just use the variable like
$MySecret and it should be populated.
Just make sure you have 1.2.8 instead of 1.2.7 as we had a bug sneak out where secret variables would not be populated in jobs correctly.
is it also possible to user secrets in APIs?
Variables are currently only available for automation scripts. We will eventually be making them global so you can access them in dashboards and APIs. For now, you can use the Get-Secret cmdlet you access your secret variables in your APIs.
Thanks for the info, does it work even if the Secret Management module is not installed?
You’ll need the secret module loaded to use that cmdlet. We include it with Universal and it can be found in the installation directory.
What’s the name of it if I want to Import it in my envirument? I guess that I need to write the searchpath for it also?
Edit: I have not written any path on my other modules I did just fill it in the GUI for the Envirument I guess it’s because its located in the ordinary folder for moduls in Windows but how do I import this one?