Skip to content

Instantly share code, notes, and snippets.

@dapacruz
Last active April 27, 2018 17:34
Show Gist options
  • Select an option

  • Save dapacruz/d03463a1a4e1429263235fdf6bd92887 to your computer and use it in GitHub Desktop.

Select an option

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