PowerShell: Encrypt and decrypt a password to plain text

Suppose I am connecting to a system that does not understand secure string? I am connecting to a non-Msft system and it wants the password in plain text.

Solution

Encrypt and store the data in text using this ——– Read-Host -Prompt “Mypassword” -AsSecureString | ConvertFrom-SecureString | Out-File “D:\Portal\MySnowpwd.key”

In your program add these 2 lines to get the password in plain text

$Getpass = Get-content “D:\Portal\MySnowpwd.key” | ConvertTo-SecureString

$pass = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Getpass))