Create #HASHED password file for PowerShell use
If you want to automate some Powershell scripts to do a job for you, and you don’t want to (and you never should) add the password in the script, then this is a great ting.
You create an encrypted txt file based on the userID and PW you define in the prompt, the file is then created with the password (password only) information in the encrypted file. The export location must be the location you want the script to run, as you can not move/copy the file to a different location after export.
So now you can use the password file with the scripts you have created
# NAME: Encrypt Password for use in Powershell
# AUTHOR: Vincent Christiansen, email@example.com
# DATE : 21/01/2016
# COMMENT: Will prompt you for username and password, and will encrypt (to hash) the password to a txt file.
# This will only be the password. And you must dump the file to the location where you are going to
# get it from in the other script
$credential = Get-Credential
$credential.Password | ConvertFrom-SecureString | Set-Content D:\Scripts\Azure_Encrypted_Password.txt
Automatically roll over the Kerberos decryption key Azure AD Connect SSO – Joachim Løe says:
[…] I’ve used this Blog article to secure the password on the server for the service account: http://www.sameie.com/2017/10/05/create-hashed-password-file-for-powershell-use/ […]
February 23, 2018 at 11:35 am