Skip to main content

Ansible Windows

winrm get winrm/config
winrm enumerate winrm/config/Listener
winrm get winrm/config/Service
winrm get winrm/config/Winrs
win:
ansible_host: 192.168.1.2
ansible_user: LocalUsername
ansible_password: Password
ansible_connection: winrm
# ansible_winrm_transport: basic
ansible_winrm_transport: ntlm

Setup

# Remove all listeners
Remove-Item -Path WSMan:\localhost\Listener\* -Recurse -Force

# Only remove listeners that are run over HTTPS
Get-ChildItem -Path WSMan:\localhost\Listener | Where-Object { $_.Keys -contains "Transport=HTTPS" } | Remove-Item -Recurse -Force

FAQ

Max retries exceeded with url

basic: HTTPSConnectionPool(host='192.168.1.1', port=5986): Max retries exceeded with url: /wsman (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x10d353940>: Failed to establish a new connection: [Errno 61] Connection refused')