Convert Plain Text To Secure String With PowerShell

Today, I will show you how to convert plain text and sensitive information to secure sting using PowerShell.

Plain Text

By default, when you save a password as a variable the password is saved as a plain text and it is not secure. Using the -AsSecureString cmdlet switch you can encrypt the text as shown below.

$password = read-host "Type secert" -AsSecureString
Type secert: ****

In the above example, I used the input I received from the user or console but I can also encrypt a variable using this method.

$password = ConvertTo-SecureString "Text" -AsPlainText -Force

Leave a Reply

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