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: **** $password
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
$password
System.Security.SecureString