Created
March 13, 2018 14:19
-
-
Save tomfanning/10be8decc97533a84d712db9e5862843 to your computer and use it in GitHub Desktop.
AWS EC2 userdata script to set Windows admin password
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<powershell> | |
$windows_admin_password="mypassword" | |
function log { | |
echo $args[0] | out-file -append c:\bootstrap-status.log | |
} | |
log "Setting Windows password" | |
$admin = [adsi]("WinNT://./administrator, user") | |
$admin.PSBase.Invoke("SetPassword", $windows_admin_password) | |
</powershell> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment