how to encrypt password in powershell code example
Example 1: password encryptin powershell
(get-credential).Password | ConvertFrom-SecureString -key (get-content C:\passwords\aes.key) | set-content "C:\Passwords\password.txt"
Example 2: password encryptin powershell
$Key = New-Object Byte[] 32
[Security.Cryptography.RNGCryptoServiceProvider]::Create().GetBytes($Key)
$Key | out-file C:\passwords\aes.key
Example 3: powershell password encryption in script
(get-credential).password | ConvertFrom-SecureString | set-content "C:\Passwords\password.txt"