Skip to content

Instantly share code, notes, and snippets.

@Dapacruz
Last active April 27, 2018 17:34
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 Dapacruz/d03463a1a4e1429263235fdf6bd92887 to your computer and use it in GitHub Desktop.
Save Dapacruz/d03463a1a4e1429263235fdf6bd92887 to your computer and use it in GitHub Desktop.
Save an encrypted password to a file and retrieve it later for use in a PowerShell script
# Save an encrypted password to a file and retrieve it later for use in a script
Read-Host -AsSecureString | ConvertFrom-SecureString | Out-File password.txt
$user = 'user'
$password = Get-Content password.txt | ConvertTo-SecureString
$creds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user, $password
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment