-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathaws_user_data.ps1
32 lines (23 loc) · 1.17 KB
/
aws_user_data.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<powershell>
Set-PSDebug -Trace 1
Write-Output "Bootstrapping machine"
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachine
Write-Output "Creating self signed cert"
$Cert = New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My -DnsName "packer"
Write-Output "Setting up WinRM"
winrm quickconfig -q
New-Item -Path WSMan:\LocalHost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $Cert.Thumbprint -Force
winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="2048"}'
winrm set winrm/config '@{MaxTimeoutms="1800000"}'
winrm set winrm/config/service '@{AllowUnencrypted="false"}'
winrm set winrm/config/service/auth '@{Basic="true"}'
winrm set "winrm/config/listener?Address=*+Transport=HTTPS" "@{Port=`"5986`";Hostname=`"packer`";CertificateThumbprint=`"$($Cert.Thumbprint)`"}"
Write-Output "Setting up firewall"
netsh advfirewall firewall add rule name="WinRM 5986" protocol=TCP dir=in localport=5986 action=allow
netsh advfirewall firewall show rule name="WinRM 5986"
Write-Output "Restarting WinRM"
net stop winrm
& c:\windows\system32\sc.exe config winrm start= auto
net start winrm
Write-Output "WinRM configuration complete."
</powershell>