1Password for VSCode - can you use secrets in Powershell scripts?
Hi all, trying to work out if the 1Password plugin for VSCode means it can be used in Powershell scripts or the integrated Powershell Console by any chance? I've reviewed all the doco and examples I can find, but I can't find anything to indicate whether it will work with Powershell in particular.
The only feature I got to work was the "Preview secrets" feature which replaced the op:// lines in text with the actual usernames/passwords from 1Password, though I couldn't figure out if you could use it with variables in scripts etc.
1Password Version: 8.7.3
Extension Version: 1.0.0 (VsCode extension)
OS Version: Windows 11
Browser:_ Not Provided
Comments
-
Hey @swanny,
Thank you for reaching out to us!
I see a couple of questions here, I'll try to break it down:
First of all, related to whether the extension can be used within VS Code's integrated terminal (where your shell is Powershell), this is not currently possible.
Related to using secret references that get replaced in your script by the underlying 1Password secrets, this is not necessarily related to the VSCode extension, it is a feature of the CLI. i.e. you can achieve this using configuration files (viaop inject
) or environment variables (viaop run
). I'll link some relevant documentation here:
https://developer.1password.com/docs/cli/secret-references
https://developer.1password.com/docs/cli/secrets-environment-variables
https://developer.1password.com/docs/cli/secrets-config-filesLet us know if this helps. Looking forward to hearing from you.
Best,
Horia0 -
Thanks Horia. I ended up chatting with some people on the 1Password Dev Slack and I confirmed that yes I needed to pipe the op:// references into "op inject", that managed to show for me how it worked with PowerShell.
0 -
Glad this got sorted out! Let us know if we can be of help with anything else.
Best,
Horia0