Skip to content

Instantly share code, notes, and snippets.

@BrendanThompson
Created February 7, 2015 04:02
Show Gist options
  • Save BrendanThompson/3c71a8a69403c3ad8053 to your computer and use it in GitHub Desktop.
Save BrendanThompson/3c71a8a69403c3ad8053 to your computer and use it in GitHub Desktop.
# Store PSCredential as SecureString
New-Variable -Name "myPassword" -Value $(Read-Host -AsSecureString | ConvertFrom-SecureString)
New-Variable -Name "myUsername" -Value "DOMAIN\Administrator"
# Construct PSCredential Object
New-Variable -Name "myCredential" -Value $(New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $myUsername, $myPassword)
# Now the Variable `myCredential` can be used as a Credential object to be passed around
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment