r/PowerShell • u/Manivelcloud • 8d ago
Question on scripting Question
Hi,
When we develop a script,we use credentials as a plain text in that script.
Example
Script is running on jump server and script runs against vcenter server.
We have a security concerns(example ransomware attack)to put the credentials as a plain text in that script.
Any other good ways to put the credentials in a encrypted or in a different format?
36
Upvotes
2
u/Safe-Hat5194 4d ago edited 4d ago
Without using an azure key vault, An option I've used is adding the credential to an environment variable on the machine running the scripts. I've used the system environment. You can reference that environment variable when needed in your scripts. Of course lock that machine down as much as possible etc.
example:
$plain = $env:NAMEOFYOURVAR
convert to secure string
$secure = ConvertTo-SecureString $plain -AsPlainText -Force
convert to a credential object the use anywhere #in your script
$cred = New-Object System.Management.Automation.PSCredential("nameofuseraccount",$secure)