How access PSU variables/Secrets when using VSCode

As subject indicates, I’m wanting to use VSCode to develop PSU scripts, but I don’t know how to access variables/secrets stored in PSU.

And a more general question is: beyond basic connectivity between VSCode and PSU (configuring token), are there other steps I need to do for full interoperability? And are there other limitations using VScode I’m not aware of? Is there a kb explaining?

To clarify, I’ve tried using: $MyVariable, $Secret:MyVariable, and Get-PSUVariable -Name MyVariable, but none work.

I’ve set the script to uses the PSU provided Powershell 7, with default “*” for variables in environment config.

PSU does not return secret values out of the platform. If you are attempting to run those scripts on your local machine, you won’t have access to any variables provided by PSU because it’s using the standard PS execution and not the PSU execution engine.

So are you saying it is not possible to use VSCode to develop scripts that need to access PSU variables/secrets?

If so then workaround is hard code variables in VSCode, get it all working, then when move to PSU, edit to use PSU variables/secrets. That correct?

That’s correct. You’d have to use that work around.

The extension could be improved to make this more seamless. The local VS PowerShell extension doesn’t know about all the PSU configuration, so it just executes the script like any other local script.

What we should do is enhance the PSU VS Code extension to provide a way to make remote execution appear local, similar other remote debugging\editing extensions.

I opened an issue to track this because I think it would be extremely helpful. PSU’s editor and debugger are okay but will never be as functional as VS Code.

2 Likes

@adam After working with PSU for past week, I agree that better integration with VSCode would be highly beneficial. The built in debugging / intellisence, etc are just not close to VSCode. I’d upvote it if there is a way.