Skip to content

Instantly share code, notes, and snippets.

@roe3p
Created June 12, 2019 10:32
Show Gist options
  • Save roe3p/97a189479edeab238e45452eba9f2252 to your computer and use it in GitHub Desktop.
Save roe3p/97a189479edeab238e45452eba9f2252 to your computer and use it in GitHub Desktop.
Encrypt a password/key and store in a file
## Encrypt a password/key in a file using Windows Credentials
## To log on as another user (e.g. a service acct), use:
## start powershell_ise -credential ""
$filename = 'D:\scripts\p_ssas_backup_password.txt'
$credential = Get-Credential -Message "Enter password" -UserName $env:username ## e.g. mydomain\p_ssas_backup'
$credential.Password | ConvertFrom-SecureString | Set-Content $filename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment