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

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 … but the question intrigued me, so I check out the help for winrm’s INVOKE verb:


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 @{command="ps";timeout="60"} -username:root -password:password -auth:basic -r:https://virtubuntu.huis.dom:1270/wsman -skipCACheck -encoding:UTF-8


Happy remote management of your unix systems from Windows 🙂

Share this on Social networks
TwitterFacebookLinkedInPin ItWhatsApp

3 thoughts on “Invoking Methods on the Xplat agent with WINRM

  • March 8, 2011 at 11:46 pm

    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
    exit 2

    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 @{command=”/opt/progress/fuse-message-broker- query -QQueue=SearchIndex.Service1.Request”;timeout=”60″} -username:root -password:password -auth:basic -r: -skipCACheck -encoding:UTF-8 | find “QueueSize”

    Any ideas on how to make this work for us?

  • March 12, 2011 at 1:28 pm

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

Comments are closed.

On this website we use first or third-party tools that store small files (cookie) on your device. Cookies are normally used to allow the site to run properly (technical cookies), to generate navigation usage reports (statistics cookies) and to suitable advertise our services/products (profiling cookies). We can directly use technical cookies, but you have the right to choose whether or not to enable statistical and profiling cookies. Enabling these cookies, you help us to offer you a better experience. Cookie and Privacy policy