Forum Topic

Thanks for your participation and contribution.


Back to Powershell

Securely Handle Clear Text Passwords in Powershell

Post a reply
637 views
i90runner1
i90runner1

Securely Handle Clear Text Passwords in Powershell

$PlainText = "MySuperSecretPassword"
$PlainText | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString | Out-File "C:\Hadoop\pwd.txt"

$securestring = Get-Content "C:\Hadoop\pwd.txt" | ConvertTo-SecureString
$BinaryString = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($securestring)
$PlainTextResult = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BinaryString)

Write-Output $PlainTextResult

1-1 of 1

Reply to this discussion

You cannot edit posts or make replies: You should be logged in before you can post.