Get-Variable with Secret variables in PSU 3

Hi

I’ve finally migrated my environment to PSU 3. Aside from minor glitches, I have one major problem. I was using Get-Variable to fetch secret variables by name, supplied from external source. I have hundreds of such secret variables and list is quite dynamic. Please advise if it’s possible to use Get-Variable or any similar method with Secret variables? This is really blocking me from launching one of core functionality on new version.
Thanks for advice in advance.

Product: PowerShell Universal
Version: 3.4.1

If you upgrade to 3.4.2, then you can use Get-ChildItem to retrieve them dynamically.

$SecretVariableName = "MySecret"
Get-ChildItem "Secret:\$SecretVariableName"
1 Like

It works, thanks a lot.
BTW, it’s nice to see how fast I can add/remove secret variables after upgrade to PSUv3.

My secret-containing variables have hyphens in their names, breaking this syntax. Any suggestions in that case?

1 Like

Answered in Scoped Variable with Hyphen in its Name - #2 by adam