Skip to content

Instantly share code, notes, and snippets.

@alastairs
Created November 25, 2012 12:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alastairs/4143393 to your computer and use it in GitHub Desktop.
Save alastairs/4143393 to your computer and use it in GitHub Desktop.
$encryptionKey = (Get-Content "C:\EncryptionKey.txt")
$encryptionKey = [System.Text.Encoding]::Unicode.GetBytes($encryptionKey)
function Get-MyCredential {
$myPassword = Get-PasswordAsSecureString
return new-object System.Management.Automation.PSCredential "My.Username", $domainAdminPassword
}
function Get-PasswordAsSecureString {
return ConvertTo-SecureString -Key $encryptionKey "Place string representation of encrypted password here"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment