Skip to content

Instantly share code, notes, and snippets.

@AdamZWinter
Last active March 16, 2021 17:21
Show Gist options
  • Save AdamZWinter/03c5b4931cac20f3dc94604fcce51f90 to your computer and use it in GitHub Desktop.
Save AdamZWinter/03c5b4931cac20f3dc94604fcce51f90 to your computer and use it in GitHub Desktop.
Powershell Password Credentials to String
#Prompts for the username/password, enter the username in the form of DomainName\UserName
$Credential = get-credential -Message "Please enter the VPM credentials"
#Converts the password to clear text to pass it through correctly as passing through a secure string does not work.
$Password = $credential.GetNetworkCredential().password
#Converts the $Credential to just the DomainName/UsernName.
$Account = $credential.UserName
echo $Password
echo $Password.GetType()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment