winrm for ansible. remember to open 5985, maybe 5986

a. upgrade powershell to 3.0 or aboveā€¦

$url = “https://raw.githubusercontent.com/jborean93/ansible-windows/master/scripts/Upgrade-PowerShell.ps1”

$file = “$env:temp\Upgrade-PowerShell.ps1”

$username = “admin”

$password = “the usual”

(New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file)

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force

Version can be 3.0, 4.0 or 5.1

&$file -Version 5.1 -Username $username -Password $password -Verbose

Set-ExecutionPolicy -ExecutionPolicy Restricted -Force

$reg_winlogon_path = “HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Winlogon”

Set-ItemProperty -Path $reg_winlogon_path -Name AutoAdminLogon -Value 0

Remove-ItemProperty -Path $reg_winlogon_path -Name DefaultUserName -ErrorAction SilentlyContinue

Remove-ItemProperty -Path $reg_winlogon_path -Name DefaultPassword -ErrorAction SilentlyContinue

b. some kind of memory hotfix for ps 3.0

$url = “https://raw.githubusercontent.com/jborean93/ansible-windows/master/scripts/Install-WMF3Hotfix.ps1”

$file = “$env:temp\Install-WMF3Hotfix.ps1”

(New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file)

powershell.exe -ExecutionPolicy ByPass -File $file -Verbose

c. actually enable winrm

$url = “https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1”

$file = “$env:temp\ConfigureRemotingForAnsible.ps1”

(New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file)

powershell.exe -ExecutionPolicy ByPass -File $file