Creating and using Password Hashes and Secure Strings with Powershell

This is how you can generate a Secure String with powershell and use it in your scripts

$secureString = Read-Host -AsSecureString
ConvertFrom-SecureString $secureString | out-file c:tmpencrypted.txt
$newString = gc C:tmpencrypted.txt | ConvertTo-SecureString

Load the Secure string from file and use it in your script:

$securePassword = Get-Content "c:tmpencrypted.txt" | ConvertTo-SecureString