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.
Save passwords securely with PowerShell
Step 1. Open PowerShell with elevated privileges
Step 2. Execute the following command.
Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File "C:\Users\securepassword.txt"