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:\temp\encrypted.txt
$newString = gc C:\temp\encrypted.txt | ConvertTo-SecureString

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

$securePassword = Get-Content c:\temp\encrypted.txt | ConvertTo-SecureString

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.