在Linux上连接Ansible的winrm模块

时间:2022-03-22 02:36:16

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

我在linux上使用ansible来管理azure上的linux和Windows VM。当我尝试从ansible使用ping Windows VM时

# ansible windows -m win_ping

I am getting below error:

我收到以下错误:

test-windows.cloudapp.net | FAILED >> {
"failed": true, 
"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", 
"parsed": false

}

The windows machine has Powershell 4 installed.

Windows机器安装了Powershell 4。

Any Ideas?

1 个解决方案

#1


0  

It was my mistake, Powershell 2.0 was installed by default in windows server 2008, and upgrading it to Powershell 3 solved the ping issue. But there was another issue called "process terminated due to stack overflow exception", the solution was discussed in below forum

这是我的错误,默认情况下在Windows Server 2008中安装了Powershell 2.0,并将其升级到Powershell 3解决了ping问题。但是还有一个问题叫做“由于堆栈溢出异常导致进程终止”,该解决方案在下面的论坛中进行了讨论

https://groups.google.com/forum/#!topic/ansible-project/Rpvuidq5XeA

#1


0  

It was my mistake, Powershell 2.0 was installed by default in windows server 2008, and upgrading it to Powershell 3 solved the ping issue. But there was another issue called "process terminated due to stack overflow exception", the solution was discussed in below forum

这是我的错误,默认情况下在Windows Server 2008中安装了Powershell 2.0,并将其升级到Powershell 3解决了ping问题。但是还有一个问题叫做“由于堆栈溢出异常导致进程终止”,该解决方案在下面的论坛中进行了讨论

https://groups.google.com/forum/#!topic/ansible-project/Rpvuidq5XeA