Skip to content

Instantly share code, notes, and snippets.

@davefunkel
Last active September 7, 2022 03:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save davefunkel/dd7376a2438573b4081932b5282de1b5 to your computer and use it in GitHub Desktop.
Save davefunkel/dd7376a2438573b4081932b5282de1b5 to your computer and use it in GitHub Desktop.
Embedded Credentials in a PowerShell Script
$username = "bad.admin@acme.com.au"
$password = "Password123!@#"
$secureStringPwd = $password | ConvertTo-SecureString -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential -ArgumentList $user, $secureStringPwd
@yiannosven
Copy link

Hey Dave,
Thank you for this.
Just thinking, the $user variable in the last line should prolly be $username no?

@tbasten
Copy link

tbasten commented Sep 7, 2022

Can you please update the documentation to be correct?

$username = "bad.admin@acme.com.au"
$password = "Password123!@#"
$secureStringPwd = $password | ConvertTo-SecureString -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential -ArgumentList $username, $secureStringPwd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment