Executing #SCOM Tasks on a Management Server


Now, it’s been really a long time since I last posted on Management Pack development. The fact is there’s not much to add to the great information you can find on the net. But with our recent migration to SCOM 2016 I had to put hands to very old custom management packs, some of them tracing back to the 2007 era. In doing this I wanted to create an agent task that should be executed by the Management Server managing that specific agent. In the old version I targeted the Microsoft.SystemCenter.HealthServiceWatcher class, but while functional a direct HealthService target would have been easier for our operators.
The first things that came to mind was to use a specific Target for the WriteAction of the Task, something like:

      <Task ID="QND.RemoteShell.Task" Accessibility="Public" Enabled="true" Target="SC!Microsoft.SystemCenter.HealthService" Timeout="120" Remotable="true">
        <Category>Custom</Category>
        <WriteAction ID="PSWA" TypeID="QND.POSHRemoting.WA" Target="SC!Microsoft.SystemCenter.ManagementServer">
           ...
          <TimeoutSeconds>60</TimeoutSeconds>
        </WriteAction>
      </Task>

unfortunately while this works for write actions used in standard rules or recoveries, is plainly ignored for Tasks. Digging into the schema I found a RunLocation attribute for the Task. It has been first introduced with the OM2012 schema and it is not documented. Searching the net returns just 9 hits and one of them states:

Agent Task Configuration – RunLocation Attribute

This attribute was added to the schema but was not implemented. It is currently considered unsupported and reserved for future use. It could be that a future product release will allow us to specify that the task should be run at the management server, but OM12 does not have this feature.

Well things change and even if it is not documented since this is an internal custom MP I decided to give it a try.

      <Task ID="QND.RemoteShell.Task" RunLocation="SC!Microsoft.SystemCenter.ManagementServer" Accessibility="Public" Enabled="true" Target="SC!Microsoft.SystemCenter.HealthService" Timeout="120" Remotable="true">
        <Category>Custom</Category>
        <WriteAction ID="PSWA" TypeID="QND.POSHRemoting.WA">
           ...
          <TimeoutSeconds>60</TimeoutSeconds>
        </WriteAction>
      </Task>

And indeed it works lake a charm. A couple of caveats:

  • it is not documented, so I suspect it is still not supported
  • it returns the full Managmenent Server that is ultimtely managing the agent, if the agent is managed through a Gateway server, the Management Server managing the Gateway is returned and not the Gateway itself.

Happy MP authoring.

-Daniel

Advertisements

,

  1. System Center Ağustos 2017 Bülten – Christopher Golden Blog
  2. System Center Ağustos 2017 Bülten – Sertac Topal
  3. System Center Ağustos 2017 Bülten – Sertaç Topal

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: