-
Notifications
You must be signed in to change notification settings - Fork 0
/
prep-windows-for-ansible.ps1
38 lines (28 loc) · 1.63 KB
/
prep-windows-for-ansible.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
33
34
35
36
37
38
# Enable RDP
Set-ItemProperty -path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\' -name 'fDenyTSConnections' -value 0
Set-ItemProperty -path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name 'UserAuthentication' -value 0
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
# Enable Ping
New-NetFirewallRule -DisplayName "ICMP Allow Ping V4" -Direction Inbound -Protocol ICMPv4 -IcmpType 8 -Action Allow
# Disable password complexity
secedit /export /cfg c:\secpol.cfg
(gc C:\secpol.cfg).replace("PasswordComplexity = 1","PasswordComplexity = 0") | Out-File C:\secpol.cfg
secedit /configure /db C:\windows\security\local.sdb /cfg c:\secpol.cfg /areas SECURITYPOLICY
rm -force c:\secpol.cfg -confirm:$false
# Add ansible user
New-LocalUser -Name ansible -Password (ConvertTo-SecureString "ansible" -AsPlainText -Force) -AccountNeverExpires -PasswordNeverExpires
Add-LocalGroupMember -Group Administrators -Member ansible
# Private networks
Foreach($p in Get-NetconnectionProfile) { $p| Set-NetConnectionProfile -NetworkCategory Private }
# WinRM
winrm quickconfig -quiet
# PSRemoting
Enable-PSRemoting
# Install SSH if not present
(Get-WindowsCapability -Online).Where{ $_.Name -like 'OpenSSH*' -and $_.State -eq "NotPresent" } | Add-WindowsCapability -Online
# Set SSH shell to powershell
Set-ItemProperty -Path HKLM:\SOFTWARE\OpenSSH -Name DefaultShell -value "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -Type String -Force
# Start SSH service & set to automatic
Set-Service -Name sshd -StartupType Automatic -Status Running
# Install NuGet package provider
Install-PackageProvider -Name Nuget -Force