How to create a SCOM group from a SQL CMDB Query

<!--[if lt IE 9]>


Comments (11)
    1. Sam Boutros says:

      nvm, resolved:
      $MS=Get-SCOMGatewayManagementServer -Name $FQDN

  1. Noah says:

    Hi Kevin, this is great!

    We’re in the initial steps of going with a system generated naming convention in attempts to get rid of naming convention drift that has become more problematic over the years so we’ve been exploring how to query our CMDB as the authoritative source.

    The question I have is would you do this on a group by group basis by having a separate MP (with a different script for each one) or would you do all your group population based off this example?

    For example we could have one SQL query to get all the server information then build each group inside your script and populate the groups 1 by 1. Also what about UNIX/Linux servers, do you have an example of that in your script?


    1. Kevin Holman says:

      Noah –

      That probably depends on how many groups we are talking. I am not a huge fan of “mega workflows” that do tons of discoveries, but that must be balanced with the number of individual workflows. If we are talking 500 groups or more, then I’d have to do some serious testing and would consider consolidation. Querying SQL is actually REALLY fast. What is slow is accessing the SDK. That would be the bottleneck for lots of small workflows. For unix/linux – you’d just change the class for the relationships, it would be the group contains Unix Computer.

      1. Noah says:

        Thanks for the reply, we’ve got a large number custom groups today but I’d say the number that I need focus on initially would be much smaller to start with. But you’ve covered the question I was more or less trying to get at with the bottleneck being on the SDK, not on the SQL side so we can figure that out.

        Today we’ve created attributes that are looking in WMI where we then determine the following support groups – OS, APP, DB, etc… and then build a dynamic group based on that. But we’re trying to get out of that model of having that information locally on each server and have SCOM populate it’s groups based on the CMDB so this is great to see an example of this out in the wild.

        Thanks again!

        1. rob1974 says:

          I’m using a different approach over the years.
          Instead of directly creating groups from a SQL query i’ve created a registry key with a group name value.
          I’ve created extended windows computer classes with that value as property and i group the computers dynamically based on the group class.
          I’ve created a SCOM task to edit the registry value.
          Daily i run an external script that:
          – gets all extended class property from SCOM (1 query to the SDK)
          – compares the values with a query from the database/CMDB (even excel sheet for some customers).
          – call the task for each value that has changed (1 SDK call for each task)

          The task is rarely fired after some time, making the impact on SCOM not such a big deal.

  2. Noah says:

    Hi Kevin,

    Is it possible to post this in a compiled MP? As of today we don’t have MP Author Pro or VS at our disposal, although I’m exploring getting a trial to of Silect to see if it would benefit us. Efforts to use the script above in our own custom MP have been challenging to say the least. Thank you in advance if possible.

    1. Noah says:

      NM – Was able to figure this out with a combination of Notepad++ and MP Author (free).

      1. rob1974 says:

        If you can do that, you might just want to give VSAE a try.

  3. GavSpeed says:

    Hi Kevin, superb article! thanks as always

    Could this example be modifed to populate a group with instances of Microsoft.SQL.Server.Database class (or SQL 14/16), which match a particular name, would this be possible? Initially, i can see that the target relationship would be Microsoft.SQL.Server.Database…

    What else would be required to populate the group?


    1. Kevin Holman says:

      Yes, it sure could be used for that, creating groups of SQL databases. You’d need to change the relationship, and the query in the script, then the discoverydata output section.

Comments are closed.

Skip to main content