Skip to content

Instantly share code, notes, and snippets.

@dylanmei
Created December 16, 2014 21:36
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dylanmei/11b4d60f4dfac54def82 to your computer and use it in GitHub Desktop.
Save dylanmei/11b4d60f4dfac54def82 to your computer and use it in GitHub Desktop.
amz.userdata
<powershell>
write-output "Running User Data Script"
write-host "(host) Running User Data Script"
# Set TZ
#cmd.exe /c tzutil /s \"Pacific Standard Time\"
cmd.exe /c net user /add packer packer
cmd.exe /c net localgroup administrators packer /add
cmd.exe /c wmic useraccount where "name='packer'" set PasswordExpires=FALSE
# Set Execution Policy
cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
C:\Windows\SysWOW64\cmd.exe /c powershell -Command "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force"
# RDP
cmd.exe /c netsh advfirewall firewall add rule name="Open Port 3389" dir=in action=allow protocol=TCP localport=3389
cmd.exe /c reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
# WinRM
write-output "Setting up WinRM"
write-host "(host) setting up WinRM"
Set-Item WSMan:\localhost\Client\TrustedHosts -Value * -Force
Restart-Service WinRM
cmd.exe /c winrm quickconfig -q
cmd.exe /c winrm quickconfig -transport:http
cmd.exe /c winrm set winrm/config @{MaxTimeoutms="1800000"}
cmd.exe /c winrm set winrm/config/winrs @{MaxMemoryPerShellMB="1024"}
cmd.exe /c winrm set winrm/config/service @{AllowUnencrypted="true"}
cmd.exe /c winrm set winrm/config/service/auth @{Basic="true"}
cmd.exe /c winrm set winrm/config/client/auth @{Basic="true"}
cmd.exe /c winrm set winrm/config/listener?Address=*+Transport=HTTP @{Port="5985"}
cmd.exe /c net stop winrm
cmd.exe /c sc config winrm start= auto
cmd.exe /c net start winrm
cmd.exe /c netsh advfirewall firewall set rule group="remote administration" new enable=yes
cmd.exe /c netsh firewall add portopening TCP 5985 "Port 5985"
</powershell>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment