I have to use passwords in a lot of my scripts.
I have an SQL server where each script has it's own database where I store passwords as an encrypted string along with any other config/test/log data. I also only allow specific users access to that database via AD. The decryption keys are also unique to each script.
This lets me keep passwords secure and lets me control who can access my apps as if the database connection fails then the app closes with a message to contact me for access.
nope, access is by Active Directory so no mater what laptop or citrix box I'm logged into I can access the database. So, this solution only works if you are in a corporate world.
Sorry, but I have to disagree: Encrypting passwords in a script together with the information required for decryption is obfuscation, not security.
Suggestion: Use the keepass CLI (kpscript), there is an UDF by @seadoggie01 available, never worked with it, just as a start: