powershell encrypting credentials using key
Think many of us, already know how to encrypt password in our powershell automation and normally we would just use "Get-Credential". This approach uses Windows Data Protection and only the same user will able to encrypt / decrypt a secure string.
Alternatively you can use a key for the same purpose. Here's my quick and simple script to encrypt a password.
So we're using our key which starts from 1 until 16 and then it encrypts our password which is "admin" into a file called "password.txt".
Lets instantiate our credential object. Its just a call to say instantiate PSCredential('username', 'password' - tho its a big longer)
We now have a object called MyCredential which stores username and password (extracted from encrypted password.txt file.
We can just pass $MyCredential username and password into our application for further execution.
Comments