forked from OctopusDeploy/OctopusDSC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aws_user_data.ps1
27 lines (21 loc) · 1.1 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
<powershell>
Write-Output -ForegroundColor green "Bootstrapping machine"
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope LocalMachine
Write-Output "Creating self signed cert"
$Cert = New-SelfSignedCertificate -CertstoreLocation Cert:\LocalMachine\My -DnsName "packer"
New-Item -Path WSMan:\LocalHost\Listener -Transport HTTPS -Address * -CertificateThumbPrint $Cert.Thumbprint -Force
Write-Output "Setting up WinRM"
winrm quickconfig -q
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
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>