Skip to content

Instantly share code, notes, and snippets.

@scarolan
Last active December 22, 2015 10:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save scarolan/6457857 to your computer and use it in GitHub Desktop.
Save scarolan/6457857 to your computer and use it in GitHub Desktop.
Powershell script to be used with the AWS user_data field, to prepare Windows instances for bootstrapping with the knife tool.
<powershell>
# Set the administrator password
$ComputerName = $env:COMPUTERNAME
$user = [adsi]"WinNT://$ComputerName/Administrator,user"
$user.setpassword("******")
# Get the instance ready for our bootstrapper, commands courtesy of Julian Dunn
winrm quickconfig -q
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="300"}'
winrm set winrm/config '@{MaxTimeoutms="1800000"}'
winrm set winrm/config/service '@{AllowUnencrypted="true"}'
winrm set winrm/config/service/auth '@{Basic="true"}'
netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" profile=public protocol=tcp localport=5985 remoteip=localsubnet new remoteip=any
</powershell>
@binamov
Copy link

binamov commented Sep 9, 2013

Don't forget to replace the ****** with a real, complex password. Win2k12 wants a password with punctuations in it too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment