Invoking Methods on the Xplat agent with WINRM

So I was testing other stuff tonight, to be honest, but I got pinged on Instant Messenger by my geek friend and colleague Stefan Stranger who pointed me at his request for help here http://friendfeed.com/sstranger/4571f39b/help-needed-on-winrs-or-winrm-and-openwsman-to

He wanted to use WINRM or any other command line utility to interact with the Xplat agent, and call methods on the Unix machine from windows. This could be very useful to – for example – restart a service (in fact it is what the RECOVERY actions in the Xplat Management Packs do, btw).

At first I told him I had only tested enumerations – such as on this other post http://www.muscetta.com/2009/06/01/using-the-scx-agent-with-wsman-from-powershell-v2/ … but the question intrigued me, so I check out the help for winrm’s INVOKE verb:

clip_image002

Which told me that you can pass in the parameters for the method to be called/invoked either as an hashtable @{KEY=”value”;KEY2=”value”}, or as an input XML file. I first tried the XML file but I could not get its format right.

After a few more minutes of trying, I figured out the right syntax.

This one works, for example:

winrm invoke ExecuteCommand http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/SCX_OperatingSystem?__cimnamespace=root/scx @{command="ps";timeout="60"} -username:root -password:password -auth:basic -r:https://virtubuntu.huis.dom:1270/wsman -skipCACheck -encoding:UTF-8

clip_image004

Happy remote management of your unix systems from Windows :-)

3 Responses to “Invoking Methods on the Xplat agent with WINRM”

  1. Ryan Taylor Says:

    So I have a question that I think you might be able to help with. We create a monitor which would read an Exit Code of 0,1,2 to report health on an activemq queue size. ActiveMQ is running on a red hat server and we can access the information pretty easily over webinterface, but we would prefer to monitor this.

    The script which resides on the Unix server is as such

    VALUE=`/opt/progress/apache-activemq-4.4.2-fuse-01-00/bin/activemq-admin query -QQueue=EmailSender.Service1.Request | grep QueueSize | awk '{ print $3 }'`

    if [ "$VALUE" -le 100 ]; then
    exit 0
    elif [ "$VALUE" -le 1000 ]; then
    exit 1
    else
    exit 2
    fi

    0= Less than 100 in the queue is healthy
    1= More than 100 but less than 1000 is warning
    2= More than 1000 is critical escalation

    We can run the script locally on the server but not able to run the script from our SCOM server. We receive SOAP-ENV:Senderwsman:AccessDeniedCIM_ERR_ACCESS_DENIED. An obvious permissions issue but I was to test using your instructions above and got this in return.

    winrm invoke ExecuteCommand http://schemas.microsoft.com/wbem/wscim/1/cim-schema/2/SCX_OperatingSystem?__cimnamespace=root/scx @{command="/opt/progress/fuse-message-broker-5.3.0.3/bin/activemq-admin query -QQueue=SearchIndex.Service1.Request";timeout="60"} -username:root -password:password -auth:basic -r:https://qtvslax1lmsq001.taservs.net:1270/wsman -skipCACheck -encoding:UTF-8 | find "QueueSize"

    Any ideas on how to make this work for us?

  2. Daniele Muscetta Says:

    Are you able to run any other simpler command (like the one in my example) with the root user thru WinRM ?

  3. Michiel Wouters Says:

    Hi Daniele,

    Thanks for sharing! Helped me a lot. I managed to Invoke a WSMan action through PowerShell. http://michielw.blogspot.nl/2013/08/scom-invoke-method-on-cross-platform.html

    Regards, Michiel

Leave a Reply

To prevent Comment Spam, we use Asirra, a Human Interactive Proof that will require you to click on pictures of Cats to set them apart from those of Dogs, rather than filling in some unreadable, distorted string of obscured and dodgy letters.

It should be easier and take you just as long.

We promise that no animal will be harmed during this classification process.