I would like to write a management pack that will allow me to retrieve the ScomID of a SCOM group or server object. Therefore, script needs to execute on the SCOM Management server (rather than the client) and the object name to be passed to whatever function/script necessary to query SCOM. Where would you start with something like this?
Functions for retrieving ScomID
$SCOMComputerID = (Get-SCOMClassInstance -Name $ComputerFQDN).ID
$SCOMGroupID = (Get-SCOMGroup $GroupName).ID
return [string] $SCOMGroupID
Here’s a slightly different approach:
The ID of the target object is available to any agent task, so write a task to simply return the ID. This task would be available for any SCOM object. To use it, locate the object in the SCOM console (via search, or a view) and run the task.
To create this task using the SCOM console:
SCOM Console > Authoring > Management Pack Objects > Tasks
Task pane > Create a New Task
Task Type = Agent Tasks / Command Line
Choose an MP
Task name = Get SCOM ID
Task target = Object, System Library (select “View all targets” and search for “object”)
Full path to file = cmd.exe
Parameters = /C “echo $Target/Id$”
You can now run the task like this:
Exporting the management pack and viewing the resulting XML may give you some ideas of how to use parameters in your own task.
And lastly, don’t forget that the ID of the object is also in the Squared Up URL for an object drilldown, which is a very easy way of finding the ID.
in my self maintenance MP, there’s an agent task to get workflow ID. what you are trying to do is very similar to that task. please take a look and hopefully it will give you some ideas. you can input these script parameters as task override parameters.
that’s covered in the second part of the workshop guide (the homework part) :). please let us know if you need help with that.