Testing WinRM Connections

I’ve been playing around with Molecule which is a great system for unit testing Ansible Roles.

Today, I had an issue when running molecule test for a Windows role I was working on. Despite the problem I was experiencing being my own fault (I was running two instances of the same Windows Vagrant box, so the winrm ports were being automatically re-numbered), I found this blog post from Steven Murawski detailing how to test if winrm is listening on the target machine directly from my Mac terminal. This was a really useful post for helping me diagnose the issue.

Checks that the WinRM service is listening

curl --header "Content-Type: application/soap+xml;charset=UTF-8" --header "WSMANIDENTIFY: unauthenticated" http://192.168.1.82:5985/wsman --data '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:wsmid="http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd"><s:Header/><s:Body><wsmid:Identify/></s:Body></s:Envelope>'

Checks that the local account can log in via WinRM using Basic Auth

curl --header "Content-Type: application/soap+xml;charset=UTF-8" http://192.168.1.82:5985/wsman --basic  -u user:password --data '<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:wsmid="http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd"><s:Header/><s:Body><wsmid:Identify/></s:Body></s:Envelope>'

Thanks Steven!

Courtesy of Steven Murawski

comments powered by Disqus