Thursday, July 17, 2014

Encryption and decryption in powershell


Encryption:

 

·         PS C:\> read-host -assecurestring | convertfrom-securestring | out-file C:\cred.txt

 

Decryption:

 

·         $PlainTextPassword= [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR( (ConvertTo-SecureString $credential.Password) ))



 

No comments :