How to save Secure String in Powershell

You need to do this for each user , only the user who saved the SecureString can call it

Write-Host "Press Enter and Enter Secure Text and Enter Again"
$secure = read-host -asSecureString | convertfrom-securestring | out-file C:\Scripts\securePassword.txt
$credential = Get-Credential
$credential.Password | ConvertFrom-SecureString | Set-Content c:\scripts\encrypted_password1.txt

For a Managed Service Account, I had to run CMD as Admin then run the below with psexec

psexec -i -u domain\gMSA$ -p ~ powershell.exe
$Secure_String_Pwd = ConvertTo-SecureString 'XXXXXXXX' -AsPlainText -Force
$Secure_String_Pwd | convertfrom-securestring | out-file C:\Scripts\securePassword.txt
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...