Hello!
I'm trying to invoke a method ("execcmd") from PowerShell (Windows Server 2012) which executes a command on a Remote Machine (CentOS 6.4) using winrm.
The method "execcmd" is member of the "Linux_OperatingSystem" class which is derived from "CIM_OperatingSystem" and signature of the method in the MOF-File is the following:
uint8 execCmd([IN] string cmd, [OUT] string out);
The following Command is working fine and I get the right output:
winrm invoke execcmd http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_OperatingSystem?CSCreationClassName=Linux_ComputerSystem+CSName=server02.domain01.com+CreationClassName=Linux_OperatingSystem+Name=server02.domain01.com
-u:root
-p:mypass
-r:http://server02:5985/wsman
-SkipCNcheck
-SkipCAcheck
-encoding:utf-8
-a:basic
'@{cmd="ps";out=""}'
After that I tried to provide the input via a XML-file like this:
winrm invoke execcmd http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_OperatingSystem?CSCreationClassName=Linux_ComputerSystem+CSName=server02.domain01.com+CreationClassName=Linux_OperatingSystem+Name=server02.domain01.com -u:root -p:mypass -r:http://server02:5985/wsman -SkipCNcheck -SkipCAcheck -encoding:utf-8 -a:basic -file:C:\Users\Administrator\Desktop\param.xml
But I get the following Error:
winrm : At C:\Users\Administrator\Desktop\OWSMAN_Beschraenkung.ps1:142 char:8+ $ret = winrm invoke execcmd + ~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : NotSpecified: (:String) [], RemoteException+ FullyQualifiedErrorId : NativeCommandError Error number: -2144108477 0x80338043 The WS-Management service cannot process the request because the XML is invalid.
Here is the XML-file. It should be right, I think... I've also checked the SOAP-Envelope (capturing with WireShark) of the working Command. The Body is actually the same as the XML-File.
<p:execcmd_INPUT xmlns:p="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_OperatingSystem"><p:cmd>ps</p:cmd><p:out>test</p:out></p:execcmd_INPUT>
Is there a specific format for this XML-file which I should use or what else could be the problem?
I'd be very thankful for a hint!
Thanks!