Menu

How to Read a Password from Command Line and Save it in Text File as Encrypted String

Some of the PowerShell commands require a password. You can directly embed a password in PowerShell commands. But, It is unwise to do it in this fashion. It can be read by ordinary users and can be compromised. The best way is to store the password as an encrypted string in text file. Even when an ordinary user read it, he wont' be able to guess the password. When a script or command need that password, you can read the encrypted password string from text file and convert it back and use it.

This article illustrates how to read a password as a secure string from command line and convert it to an encrypted string and save it in text file.