# Connecting winrm module from Ansible on Linux

**URL:** <https://forum.ansible.com/t/connecting-winrm-module-from-ansible-on-linux/17550>\
**Category:** Ansible Project\
**Tags:** azure, windows\
**Created:** [February 18, 2015, 1:12pm UTC](https://forum.ansible.com/t/connecting-winrm-module-from-ansible-on-linux/17550 "2015-02-18T13:12:57Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![satheesh\_kumar](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@satheesh\_kumar](https://forum.ansible.com/u/satheesh_kumar)\
**Post date:** [February 18, 2015, 1:12pm UTC](https://forum.ansible.com/t/connecting-winrm-module-from-ansible-on-linux/17550/1 "2015-02-18T13:12:57Z")

</div>

> |   
>   
>   
>   
> I am using ansible hosted on linux to manage both linux and Windows VMs on azure. When I try to ping windows VMs from ansible using  
>   
>   
>   
> `<br># ansible windows -m win_ping<br><br>`  
>   
>   
>   
> I am getting below error:  
>   
>   
>   
> `<br>test-windows.cloudapp.net | FAILED >> {<br>"failed": true, <br>"msg": "The term 'ConvertFrom-Json' is not recognized as the name of a cmdlet, function\r\n, script file, or operable program. Check the spelling of the name, or if a pat\r\nh was included, verify that the path is correct and try again.\r\nAt C:\\Users\\coremedia\\AppData\\Local\\Temp\\ansible-tmp-1424263716.9-1357614051035\r\n00\\win_ping.ps1:54 char:67\r\n+ $parameters = Get-Content $arguments[0] | ConvertFrom-Json <<<< ;\r\n + CategoryInfo : ObjectNotFound: (ConvertFrom-Json:String) [], Co \r\n mmandNotFoundException\r\n + FullyQualifiedErrorId : CommandNotFoundException\r\n \r\nThe term 'ConvertTo-Json' is not recognized as the name of a cmdlet, function, \r\nscript file, or operable program. Check the spelling of the name, or if a path \r\nwas included, verify that the path is correct and try again.\r\nAt C:\\Users\\coremedia\\AppData\\Local\\Temp\\ansible-tmp-1424263716.9-1357614051035\r\n00\\win_ping.ps1:85 char:31\r\n+ echo $obj | ConvertTo-Json <<<< -Depth 99\r\n + CategoryInfo : ObjectNotFound: (ConvertTo-Json:String) [], Comm \r\n andNotFoundException\r\n + FullyQualifiedErrorId : CommandNotFoundException\r\n \r\n", <br>"parsed": false<br><br>`  
>   
>   
>   
> }  
>   
>   
>   
> The windows machine has Powershell 4 installed.  
>   
>   
>   
> Any Ideas?  
>   
>   
>   
> |

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [February 18, 2015, 2:19pm UTC](https://forum.ansible.com/t/connecting-winrm-module-from-ansible-on-linux/17550/2 "2015-02-18T14:19:09Z")

</div>

I would have to say double check that you do have powershell 4 installed and operational.

That cmdlet was introduced in powershell 3.

---

<div class="post-metadata">

**Author:** ![satheesh\_kumar](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@satheesh\_kumar](https://forum.ansible.com/u/satheesh_kumar)\
**Post date:** [February 18, 2015, 2:30pm UTC](https://forum.ansible.com/t/connecting-winrm-module-from-ansible-on-linux/17550/3 "2015-02-18T14:30:56Z")

</div>

[![](https://lh4.googleusercontent.com/-pu2-p0Cpclg/VOSiF7CsBJI/AAAAAAAAALY/VBuXYEijdZI/s320/ps4.jpg)](https://lh4.googleusercontent.com/-pu2-p0Cpclg/VOSiF7CsBJI/AAAAAAAAALY/VBuXYEijdZI/s1600/ps4.jpg)

[![](https://lh4.googleusercontent.com/-pu2-p0Cpclg/VOSiF7CsBJI/AAAAAAAAALY/VBuXYEijdZI/s320/ps4.jpg)](https://lh4.googleusercontent.com/-pu2-p0Cpclg/VOSiF7CsBJI/AAAAAAAAALY/VBuXYEijdZI/s1600/ps4.jpg)

Hi Matt,

Please find my Powershell version

---

<div class="post-metadata">

**Author:** ![satheesh\_kumar](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@satheesh\_kumar](https://forum.ansible.com/u/satheesh_kumar)\
**Post date:** [February 20, 2015, 10:52am UTC](https://forum.ansible.com/t/connecting-winrm-module-from-ansible-on-linux/17550/4 "2015-02-20T10:52:21Z")

</div>

Hi,

It was my mistake that I tried connecting to Windows server 2008 (PS2), whereas I am checking PS version from Windows server 2012.

Now, I upgraded Windows server 2008 poweshell version to PS3, using same steps mentioned in ansible for windows documentstion.

It successfuly pings, but when i run any other commands for like

# ansible windows -m setup -vvvv

I am getting below error:

failed: [[winserver.cloudapp.net](http://winserver.cloudapp.net)] =\> {“failed”: true, “parsed”: false}

Process is terminated due to StackOverflowException.

STACKTRACE:

$ ansible windows -m setup -vvvv  
\<[winserver.cloudapp.net](http://winserver.cloudapp.net)\> ESTABLISH WINRM CONNECTION FOR USER: coremedia on PORT 5986 TO [winserver.cloudapp.net](http://winserver.cloudapp.net)  
\<[winserver.cloudapp.net](http://winserver.cloudapp.net)\> WINRM CONNECT: transport=plaintext endpoint=[https://winserver.cloudapp.net:5986/wsman](https://winserver.cloudapp.net:5986/wsman)  
\<[winserver.cloudapp.net](http://winserver.cloudapp.net)\> REMOTE\_MODULE setup  
\<[winserver.cloudapp.net](http://winserver.cloudapp.net)\> EXEC (New-Item -Type Directory -Path $env:temp -Name “ansible-tmp-1424429207.53-10354320142574”).FullName | Write-Host -Separator ‘’;  
\<[winserver.cloudapp.net](http://winserver.cloudapp.net)\> WINRM EXEC ‘PowerShell’ [‘-NoProfile’, ‘-NonInteractive’, ‘-EncodedCommand’, ‘KABOAGUAdwAtAEkAdABlAG0AIAAtAFQAeQBwAGUAIABEAGkAcgBlAGMAdABvAHIAeQAgAC0AUABhAHQAaAAgACQAZQBuAHYAOgB0AGUAbQBwACAALQBOAGEAbQBlACAAIgBhAG4AcwBpAGIAbABlAC0AdABtAHAALQAxADQAMgA0ADQAMgA5ADIAMAA3AC4ANQAzAC0AMQAwADMANQA0ADMAMgAwADEANAAyADUANwA0ACIAKQAuAEYAdQBsAGwATgBhAG0AZQAgAHwAIABXAHIAaQB0AGUALQBIAG8AcwB0ACAALQBTAGUAcABhAHIAYQB0AG8AcgAgACcAJwA7AA==’]  
\<[winserver.cloudapp.net](http://winserver.cloudapp.net)\> WINRM RESULT \<Response code 0, out “C:\Users\coremedia\A”, err “”\>  
\<[winserver.cloudapp.net](http://winserver.cloudapp.net)\> PUT /tmp/tmpgISwtQ TO C:\Users\coremedia\AppData\Local\Temp\ansible-tmp-1424429207.53-10354320142574\setup  
\<[winserver.cloudapp.net](http://winserver.cloudapp.net)\> WINRM PUT /tmp/tmpgISwtQ to C:\Users\coremedia\AppData\Local\Temp\ansible-tmp-1424429207.53-10354320142574\setup.ps1 (offset=0 size=2037)  
\<[winserver.cloudapp.net](http://winserver.cloudapp.net)\> WINRM PUT /tmp/tmpgISwtQ to C:\Users\coremedia\AppData\Local\Temp\ansible-tmp-1424429207.53-10354320142574\setup.ps1 (offset=2037 size=2037)  
\<[winserver.cloudapp.net](http://winserver.cloudapp.net)\> WINRM PUT /tmp/tmpgISwtQ to C:\Users\coremedia\AppData\Local\Temp\ansible-tmp-1424429207.53-10354320142574\setup.ps1 (offset=4074 size=2037)  
\<[winserver.cloudapp.net](http://winserver.cloudapp.net)\> WINRM PUT /tmp/tmpgISwtQ to C:\Users\coremedia\AppData\Local\Temp\ansible-tmp-1424429207.53-10354320142574\setup.ps1 (offset=6111 size=2037)  
\<[winserver.cloudapp.net](http://winserver.cloudapp.net)\> WINRM PUT /tmp/tmpgISwtQ to C:\Users\coremedia\AppData\Local\Temp\ansible-tmp-1424429207.53-10354320142574\setup.ps1 (offset=8148 size=446)  
\<[winserver.cloudapp.net](http://winserver.cloudapp.net)\> PUT /tmp/tmpt9SWcw TO C:\Users\coremedia\AppData\Local\Temp\ansible-tmp-1424429207.53-10354320142574\arguments  
\<[winserver.cloudapp.net](http://winserver.cloudapp.net)\> WINRM PUT /tmp/tmpt9SWcw to C:\Users\coremedia\AppData\Local\Temp\ansible-tmp-1424429207.53-10354320142574\arguments (offset=0 size=2)  
\<[winserver.cloudapp.net](http://winserver.cloudapp.net)\> EXEC PowerShell -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -File “C:\Users\coremedia\AppData\Local\Temp\ansible-tmp-1424429207.53-10354320142574\setup.ps1” “C:\Users\coremedia\AppData\Local\Temp\ansible-tmp-1424429207.53-10354320142574\arguments”; Remove-Item "C:\Users\coremedia\AppData\Local\Temp\ansible-tmp-1424429207.53-10354320142574" -Force -Recurse;  
\<[winserver.cloudapp.net](http://winserver.cloudapp.net)\> WINRM EXEC ‘PowerShell’ [‘-NoProfile’, ‘-NonInteractive’, ‘-EncodedCommand’, ‘UABvAHcAZQByAFMAaABlAGwAbAAgAC0ATgBvAFAAcgBvAGYAaQBsAGUAIAAtAE4AbwBuAEkAbgB0AGUAcgBhAGMAdABpAHYAZQAgAC0ARQB4AGUAYwB1AHQAaQBvAG4AUABvAGwAaQBjAHkAIABVAG4AcgBlAHMAdAByAGkAYwB0AGUAZAAgAC0ARgBpAGwAZQAgACIAQwA6AFwAVQBzAGUAcgBzAFwAYwBvAHIAZQBtAGUAZABpAGEAXABBAHAAcABEAGEAdABhAFwATABvAGMAYQBsAFwAVABlAG0AcABcAGEAbgBzAGkAYgBsAGUALQB0AG0AcAAtADEANAAyADQANAAyADkAMgAwADcALgA1ADMALQAxADAAMwA1ADQAMwAyADAAMQA0ADIANQA3ADQAXABcAHMAZQB0AHUAcAAuAHAAcwAxACIAIAAiAEMAOgBcAFUAcwBlAHIAcwBcAGMAbwByAGUAbQBlAGQAaQBhAFwAQQBwAHAARABhAHQAYQBcAEwAbwBjAGEAbABcAFQAZQBtAHAAXABhAG4AcwBpAGIAbABlAC0AdABtAHAALQAxADQAMgA0ADQAMgA5ADIAMAA3AC4ANQAzAC0AMQAwADMANQA0ADMAMgAwADEANAAyADUANwA0AFwAXABhAHIAZwB1AG0AZQBuAHQAcwAiADsAIABSAGUAbQBvAHYAZQAtAEkAdABlAG0AIAAiAEMAOgBcAFUAcwBlAHIAcwBcAGMAbwByAGUAbQBlAGQAaQBhAFwAQQBwAHAARABhAHQAYQBcAEwAbwBjAGEAbABcAFQAZQBtAHAAXABhAG4AcwBpAGIAbABlAC0AdABtAHAALQAxADQAMgA0ADQAMgA5ADIAMAA3AC4ANQAzAC0AMQAwADMANQA0ADMAMgAwADEANAAyADUANwA0AFwAIgAgAC0ARgBvAHIAYwBlACAALQBSAGUAYwB1AHIAcwBlADsA’]  
\<[winserver.cloudapp.net](http://winserver.cloudapp.net)\> WINRM RESULT \<Response code 0, out “”, err “”\>  
[winserver.cloudapp.net](http://winserver.cloudapp.net) | FAILED \>\> {  
“failed”: true,  
“msg”: “”,  
“parsed”: false  
}

Can somebody help me out please

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [February 20, 2015, 1:36pm UTC](https://forum.ansible.com/t/connecting-winrm-module-from-ansible-on-linux/17550/5 "2015-02-20T13:36:19Z")

</div>

I think I had this on a fresh Windows Server 2008 R2 installation which had not received any windows updates.  
If I recall there was a bug which caused the maximum amount of memory available to processes started by powershell to be very small, which was fixed in a subsequent hotfix.  
Is your windows server 2008 machine fully up to date with windows updates?

Jon

---

<div class="post-metadata">

**Author:** ![satheesh\_kumar](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@satheesh\_kumar](https://forum.ansible.com/u/satheesh_kumar)\
**Post date:** [February 20, 2015, 2:48pm UTC](https://forum.ansible.com/t/connecting-winrm-module-from-ansible-on-linux/17550/6 "2015-02-20T14:48:25Z")

</div>

Thanks a ton you Jon. You saved me, I was struggling for a day 🙂

---

<div class="post-metadata">

**Author:** ![Trond\_Hindenes](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Trond\_Hindenes](https://forum.ansible.com/u/Trond_Hindenes)\
**Post date:** [February 20, 2015, 8:22pm UTC](https://forum.ansible.com/t/connecting-winrm-module-from-ansible-on-linux/17550/7 "2015-02-20T20:22:46Z")

</div>

John, do you know what update is needed? We could add it to the winrm provisioning script as a check?

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [February 20, 2015, 11:45pm UTC](https://forum.ansible.com/t/connecting-winrm-module-from-ansible-on-linux/17550/8 "2015-02-20T23:45:55Z")

</div>

This is the hotfix

[http://support.microsoft.com/kb/2842230](http://support.microsoft.com/kb/2842230)

All the best, Jon

---

<div class="post-metadata">

**Author:** ![satheesh\_kumar](https://avatars.discourse-cdn.com/v4/letter/s/bcef8e/32.png) [@satheesh\_kumar](https://forum.ansible.com/u/satheesh_kumar)\
**Post date:** [February 22, 2015, 11:15am UTC](https://forum.ansible.com/t/connecting-winrm-module-from-ansible-on-linux/17550/9 "2015-02-22T11:15:11Z")

</div>

Hi Trond, Do you have sample provisioning scrpt to check this particular windows patch? If yes, can you please share me

---

<div class="post-metadata">

**Author:** ![Trond\_Hindenes](https://avatars.discourse-cdn.com/v4/letter/t/96bed5/32.png) [@Trond\_Hindenes](https://forum.ansible.com/u/Trond_Hindenes)\
**Post date:** [February 25, 2015, 1:15pm UTC](https://forum.ansible.com/t/connecting-winrm-module-from-ansible-on-linux/17550/10 "2015-02-25T13:15:26Z")

</div>

Not on hand for PS v3.0. I’ll need to do some digging (probably using WMI to check that the hotfix is present for 2008R2 OS machines).
