Monthly Archives: November 2016

PowerShell: Read Secure String and Convert Back to Plain Text

Here’s a quick way to read in a secure string and then convert it back to plain text: $SecureString = Read-Host -Prompt "What is the secret?" -AsSecureString $ClearTextString = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureString)) Also, take a look at the ConvertTo-SecureString and ConvertFrom-SecureString functions … Continue reading

Posted in PowerShell | Leave a comment

PowerShell: Generate a Pseudo-Random String

Here’s a quick way to generate a pseudo-random string with PowerShell: $Length = 20 $AllowedCharacters = "abcdefghijklmnopqrstuvwxyz0123456789".ToCharArray() $MyRandomString = -join (Get-Random -Count $Length -InputObject $AllowedCharacters) Hope this helps!

Posted in PowerShell | Leave a comment