summaryrefslogtreecommitdiff
path: root/packer/files/scripts/windows/enable-winrm-http.ps1
diff options
context:
space:
mode:
Diffstat (limited to 'packer/files/scripts/windows/enable-winrm-http.ps1')
-rw-r--r--packer/files/scripts/windows/enable-winrm-http.ps129
1 files changed, 29 insertions, 0 deletions
diff --git a/packer/files/scripts/windows/enable-winrm-http.ps1 b/packer/files/scripts/windows/enable-winrm-http.ps1
new file mode 100644
index 0000000..44d8e70
--- /dev/null
+++ b/packer/files/scripts/windows/enable-winrm-http.ps1
@@ -0,0 +1,29 @@
+Get-NetConnectionProfile | Set-NetConnectionProfile -NetworkCategory Private
+
+New-ItemProperty `
+ -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System' `
+ -Name LocalAccountTokenFilterPolicy `
+ -Value 1 `
+ -Force | Out-Null
+
+winrm quickconfig -q
+winrm quickconfig -transport:http
+winrm set winrm/config '@{MaxTimeoutms="1800000"}'
+winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="800"}'
+winrm set winrm/config/service '@{AllowUnencrypted="true"}'
+winrm set winrm/config/service/auth '@{Basic="true"}'
+winrm set winrm/config/service/auth '@{CredSSP="true"}'
+winrm set winrm/config/listener?Address=*+Transport=HTTP '@{Port="5985"}'
+Start-Process -FilePath C:\Windows\System32\cmd.exe -ArgumentList "/c sc.exe config WinRM start= delayed-auto" -Wait -Verbose
+Start-Process -FilePath C:\Windows\System32\cmd.exe -ArgumentList "/c sc.exe stop WinRM" -Wait -Verbose
+Start-Process -FilePath C:\Windows\System32\cmd.exe -ArgumentList "/c sc.exe start WinRM" -Wait -Verbose
+
+New-NetFirewallRule `
+ -DisplayName WINRM-HTTP-In-TCP `
+ -Direction Inbound `
+ -Action Allow `
+ -Protocol TCP `
+ -LocalPort 5985 | Out-Null
+
+#netsh advfirewall firewall set rule group="Windows Remote Administration" new enable=yes
+#netsh advfirewall firewall set rule name="Windows Remote Management (HTTP-In)" new enable=yes action=allow remoteip=any