The ConvertFrom-SecureString cmdlet converts a secure string (System.Security.SecureString) into an encrypted standard string (System.String). Unlike a secure string, an encrypted standard string can be saved in a file for later use. The encrypted standard string can be converted back to its secure string format by using the ConvertTo-SecureString
cmdlet.
1 2 3 4 5 6 7 8 |
# Ver password seguro $var = (Get-Credential).Password | ConvertFrom-SecureString $var > pass.txt $credenciales = gc .\pass.txt | ConvertTo-SecureString $BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR(($credenciales)) $PlainPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) $PlainPassword |