SCOM Visual Studio Authoring – Basic Seed Class Discovery

In this blog post I’ll go over a basic seed class discovery. Basically a seed class is a class that normally utilizes a low cost discovery method (in this case a registry discovery) across a large group of servers to narrow the scope of which higher cost discoveries (A script in this case) then target in order to populate more classes.

So to further illustrate, say you have 1000 servers and an application that has 2 server types. You would like to create a class for each server type and you have a few things that can be used to identify the 2 server types:

  • Both server types have a registry key “HKLM:SOFTWARE\Leibundgutski”
  • One server type can be uniquely identified by the existence of a folder”C:\Leibundgutski”
  • The other server type can be uniquely identified by the existence of a file “C:\Andy.tx”

OK, so assume you have 3 of each server type for a total of 6 servers that represent your application and you want one class for each server type (2 classes in total). You have some options to discover them:

  1. High Cost – You create 2 classes that utilize a scripted discovery that target something like Windows Server Computer. Scripts have a lot of overhead and are considered a high cost method of doing things so what would happen is you have 2 scripts running on each of the 1000 servers each time the discoveries are ran to populate the two classes. That’s a lot of scripts (2000 scripts ran)!
  2. Low Cost – You create 3 classes. One seed class that targets that same Windows Server Computer and then 2 more classes, one for each server type, that target the seed class. The seed class utilizes a registry discovery which is a very low cost method of discovery. The registry key only exists on the 6 (total) application servers so only those 6 servers are populated within the seed class. Then what you do is run the higher cost scripted discoveries against that seed class and now you’re only running 12 high cost scripted discoveries across your environment.

If you haven’t guessed number 2 is the way to go. What I’ll be going over today is how to author a basic seed class discovery with Visual Studio. The code can be found here:

Alright so we’ll start with the seed class


This is the class that represent all 6 application servers that we will then use as a target for the other two classes

  • ID – This uniquely identifies the class within the management pack
  • Comment – Comments about the class, put whatever you want in there
  • Accessibility – Public, when set to true this class can be used by other management packs provided you seal this management pack
  • Abstract – false, abstract classes have no instances and exist only to act as a base class for other classes. Don’t worry about this for now, consult the documentation if you want to know more (links to class documentation are in my MP)
  • Base – This is the class you are basing your class off of
  • Hosted – False, this is not hosted by another class
  • Singleton – False, this class has unique instances that will be discovered (IE its not a group or anything like that. Each discovered server is separate)

Next, seed class discovery


This is a registry base discovery used to populate the seed class. It discovers a server instance when the registry key HKLM\Software\Leibundgutski is found.


  • ID – BasicSeedDiscovery.LeibundgutskiRegKey.Discovery – This is the name used to uniquely identify this discovery in the management pack.
  • Target – Windows!Microsoft.Windows.Server.Computer” – This is the class the discovery targets. “Windows” is a reference to the
    Microsoft.Windows.Library management pack and “Microsoft.Windows.Server.Computer is a class within that mp.
  • Remotable – true – this workflow can run for agentless monitoring.
  • Enabled – true – this discovery is enabled. It will run by default once its imported.

DiscoveryClass – BasicSeedDiscovery.Seed.Class – This is the class the discovery will discover.


  • ID – “DS” – This is the name that uniquely identifies this datasource within the scope of this discovery.
  • TypeID – “Windows!Microsoft.Windows.FilteredRegistryDiscoveryProvider” – “Windows” is a reference to the
    Microsoft.Windows.Library management pack and “Microsoft.Windows.FilteredRegistryDiscoveryProvider” is a registry discovery datasource within that management pack that I’m for this discovery.
  • ComputerName – “$Target/Property[Type=”Windows!Microsoft.Windows.Computer”]/PrincipalName$” – This works out to be the computer name that the discovery is being ran on. Its a property of a parent class of Microsoft.Windows.Server.Computer.
  • AttributeName – “LeibundgutskiKeyExists” – This uniquely identifies the value this registry attribute definition is pulling from the registry.
  • Path – “SOFWARE\Leibundgutski” – This is the location in the registry that the registry attribute definition is looking at.
  • PathType – “0” – zero specifies that we’re looking for  a registry key.
  • AttributeType – “0” – zero specifies that we are returning a true/false value (does it exist or not)
  • Frequency – “86400” how often does the discovery run in seconds (once a day)
  • ClassID – “$MPElement[Name=”BasicSeedDiscovery.Seed.Class”]$” – This reprisendts the class being discovered
  • InstanceSettings
    • Name – “$MPElement[Name=”Windows!Microsoft.Windows.Computer”]/PrincipalName$” – The parent of our seed class “Microsoft.Windows.Computer” has a primary key of PrincipalName which is required to be discovered. This is referencing which value to populate
    • Value – “$Target/Property[Type=”Windows!Microsoft.Windows.Computer”]/PrincipalName$” – It looks kind of weird but the class we are populating (the seed class) is based on the same class as the seed discovery targets. So we are referencing the PrincipalName of the discoveries target class to populate our seed class which in this case are the same.
  • XPathQuery
    • XPathQuery- “Values/LeibundgutskiKeyExists” – This represents the value we pulled in the RegistryAttributeDefinition.
    • operation – “Equal” – The conditional parameter that is used to compare the XPathQuery and Value.
    • Value – “true” – if the value held within the RegistryAttributeDefinition is true then discover the server.

Alright, that’s how you populate the seed class. Next we’ll go over the seedling classes and how they work.


So I’ll just go over major differences in these classes from the seed class. Each of these classes represent a particular type of server. One, a type of server that contains a folder c:\Leibundgutski, and the other which represents a type server that contains a file c:\Andy.txt. The other important difference is the base of these seedling classes is the seed class. Notice that instead of targeting all server computers like the seed class does I’m just targeting the seed class itself. In other words only the computers that contain the registry key HKLM\Software\Leibundgutski will have the logic that looks for the folder or file ran on it.

Now I’ll go over the seedling discovery script (LocationDiscovery.vbs)


This script is used by each of the seedling discoveries to populate their classes. It uses conditional if/then logic against the sLocation argument to determine whether to populate (see CreateClassInstance) either the folder or file class. Or both if they both happened to exist. Some of the SCOMey code and considerations to take note of in the script is that every script that is used in SCOM will need to bring in the SourceId and ManagedEntityID. I believe these are used to keep track of the workflow within SCOM. You’ll also need to initiate the “MOM.ScriptAPI” which the script uses to interact with SCOM. Notice the oAPI.CreateDiscoveryData. That is creating the object used to surface the discovery data to the class using the “CreateClassInstance” and then on to the “AddProperty” which is used to populate the key of a parent class (Microsoft.Windows.Computer). Note, you’ll need to populate the key property of any classes in the class hierarchy that contains a key property. At the end is the oAPI.Return which returns the discovery data to the workflow so it can populate the class. One last thing to note is the LogScriptEvent which creates a logging entry (if bDebug is true) in the Operations Manager event log on the target computer.

Alright, lastly is the discovery configuration for the seedling classes


Each of the discoveries individually call the LocationDiscovery.vbs script to populate their seedling class.


  • ID – This is used to uniquely identify the discoveries within the management pack
  • Target – This is the class the discovery targets (the seed discovery for both above)
  • Remotable – Whether the discovery can be used for agentless monitoring
  • Enabled – T/F is the discovery enabled by default


  • ID – This is used to uniquely identify the datasource within the scope of the discovery
  • TypeID – This is referencing to a datasource configuration in the “Microsoft.Windows.Library” MP “Microsoft.Windows.TimedScript.DiscoveryProvider” which run a script on a schedule
  • IntervalSeconds – How often the script is ran in seconds
  • ScriptName – The name of the script
  • Arguments – These are the arguments passed to the script. See the description of how the script works above for information on the individual arguments
  • ScriptBody – Although you could just put the script in here I create a script item in visual studio and use an IncludeFileContent (see the Scripts\VBScript folder in the project) to reference it.
  • TimeoutSeconds – How many seconds before the script is set to time out.

That’s all for today, hope it was helpful. Next time I think I’ll skip around again and show you how to do a scripted monitor.

Site Index




SCOM Visual Studio Authoring – VBScript and PowerShell Based Alert Rules (Part 1)

In this series of posts I’ll be going over both VBScript and PowerShell based alert rules. The first one will be the VBScript based alert rule which looks for the existence of a folder c:\Leibundgutski and alerts if it is detected. Secondly I’ll cover a PowerShell based alert rule in part 2 which looks for the existence of a file c:\Leibundgutski\Andy.txt and alerts if it is detected.

First things first, the complete solution is available for download here:

For the VBScript alert rule I’ll start by explaining how the script works


  • Ok, the first thing worth noting is that this script will accept two parameters from the DataScource “sFolderLocation” and “bDebug”. sFolderLocation is the folder that the script will look for to determine if their is an error condition or not. In this case by default its the folder c:\Leibundgutski but it can be overridden to whatever you like in the console. The bDebug parameter (True/False) just tells the script if I want it to enter an event log entry each time it runs or discovers and error condition.
  • Set oAPI = CreateObject(“MOM.ScriptAPI”) – This is calling the SCOM scripting API for use in the script.
  • Set oBag = oAPI.CreatePropertyBag() – This is using the SCOM scripting API to create a property bag object. Think of it as a “bag” you can put things into and then return to the SCOM workflow.
  • Call oAPI.LogScriptEvent(“VBScriptProbe.vbs”,101,0,”VBScriptProbe.vbs executed”) – Use the LogScriptEvent to log events to the Operations Manager event log
  • oBag.AddValue “Result”, “BAD” – Here I’m creating a property of “Result” in the bag with a value of either GOOD or BAD that will be used to determine whether or not to alert.
  • oBag.AddValue “sFolderLocation”, sFolderLocation – Here I’m creating a property of “sFolderLocation” with the value of the folder that is being monitored for later use in the alert description.
  • oAPI.Return(oBag) – Finally when its all done we return the bag to the DataSource\Workflow.

VBScript DataSourceVBscriptAlertRuleDataSouce1The DataSouce is where you create a configuration for your VBScript. This particular DataSource includes the configuration for how often the script is ran. Here’s the DataSourceModuleType Documentation:


  • ID – “ScriptedAlertRule.VBScriptProbe.DataSource” – This is the unique name used to reference the DataSource within the management pack.
  • Accessibility – “Internal” – That indicates the DataSource can only be referenced within this management pack, other MPs cannot use it.

Configuration – These Items are used to initiate the variables that are passed to the MemberModules. These variables will all be set in the actual rule configuration.

  • name=”IntervalSeconds” type=”xsd:integer” – Setting for how often the script will be ran
  • name=”TimeoutSeconds” type=”xsd:integer” – How long ths script runs before it times out
  • name=”sFolderLocation” type=”xsd:string” – The location of the folder to monitor
  • name=”bDebugFlag” type=”xsd:boolean” – Whether or not the script will be ran in debug mode (if its true it will write an event log entry, check out the script for how that works)

OverridableParameters – Notice I’m setting all the configuration items as overridable. None of them have to be, it just allows the option for each variable to be overridden in the console.The IDs for the overridable parameters could be named anything you like, I make them the same for easy readability. The part that is actually referencing each configuration item is the $Config/VariableName$ portion.

MemberModules – This is where you pass the variables to the script, and set the configuration items for its DataSource.

DataSource – So the datasource we’re creating is actually just a configuration for another datasource that combines a VBScript probe with a scheduler.

  • ID – “DS” this is the name used to reference this module within the scope of the datasource
  • TypeID – “Windows!Microsoft.Windows.TimedScript.PropertyBagProvider” – The Windows! portion is a reference to the “Microsoft.Windows.Library” MP and Microsoft.Windows.TimedScript.PropertyBagProvider is the datasource within that MP that we are passing our configuration to which runs the VBScript and a scheduler.
  • <IntervalSeconds> – This is where the configuration for how often the script is ran via the scheduler for the script
  • <SyncTime /> – I’m opting not to use this here. This would Sync the script across all the systems its ran on. There are use cases for doing this but be careful. Say all these systems are on a virtual host and all running at the same time and your script is a bit resource intensive you’ll end up with an angry virtual host.
  • <ScriptName> – The name of the script.
  • <Arguments> – The arguments being passed to the script.
  • <ScriptBody> – Rather than sticking the script here I separate out the script and reference it here to keep things clean
  • <TimeoutSeconds> – This is where the config item for how long the script runs before it times out.

Composition – “DS” – There’s only one member in this module, DS. This is where you call out the order of which things are ran in a datasource.

OutputType – System!System.PropertyBagData – This is indicating that we’re expecting an object from the script to pass up through the workflow to the rule.

VBScript Rule


Rule – The star of the show, this is where it all comes together; the script, the schedule, the alert. Rule documentation:

  • ID – “ScriptedAlertRule.VBScriptProbe.AlertRule” – This is the unique name used for referencing the rule within the management pack.
  • Enabled – Is the rule enabled by default or not (overridable in the console)
  • Target – “Windows!Microsoft.Windows.Server.Computer” – Winodws! is a reference to the “Microsoft.Windows.Library” MP and “Microsoft.Windows.Server.Computer” is a target class within that MP that we are targeting the rule against.
  • ConfirmDelivery, Remotable, Priority, and DiscardLevel – you can look them up in the documentation above if you like, they are all optional parameters. Nothing super relevant to what we are doing here.

Category – Custom – You would think rule right, but no its not an option and it doesn’t make much sense but I don’t make the “rules”… lol

DataSource – Here’s where we set the default values that are passed down the various configurations of the workflow.

  • ID – “VBScriptProbe” – This is the unique name for this datasource within the scope of the rule.
  • TypeID – “ScriptedAlertRule.VBScriptProbe.DataSource” – This is the datasource we created above and are referencing to pass our variables IntervalSeconds, TimeoutSeconds, sFolderLocation, and bDebugFlag to.

ConditionDetection – The property bag that we created in the script, and passed up throught the datasource is surfaced here where we use the data in it to determine if there is an error condition for the property of “result” equaling “BAD”. If the condition detection is met the rule moves along to the write action. These can be made with multiple expressions for more advanced logic if necessary. We’ll go over that some other time.

WriteAction – This is the configuration for the alert.

  • ID – “GenerateAlert” – This is the unique name for this write action within the scope of the rule.
  • TypeID – “Health!System.Health.GenerateAlert” – Health! is a reference to the System.Health.Library MP and the System.Health.GenerateAlert is a write action within it. System.Health.GenerateAlert Documentation:
  • Priority – Alert Priority – 0-2 (low, medium, high)
  • Severity – Alert Severity – 0-2 (information, warning, error)
  • AlertmessageID – “$MPElement[Name=”ScriptedAlertRule.VBScriptProbe.AlertRule_AlertMessageResourceID”]$” – This is the unique name given to the alert and is used for providing “friendly” name within the console, more on this in a moment (see “string resource” below).
  • AlertParameters – These are used as variables that can be surfaced to the alert message within the console. Here’s a good resource for various options for parameters: The alert parameter for this rule is the folder name which was referenced from the property bag created in the VBScript.

String Resource – This one is kinda weird, but in essence it represents the alert message and is required if you’re going to create an alert. Notice its the same as the AlertMessageID (without all the MPElement drapery).


Language Packs – Not required but if you want your stuff to look pretty in the console you’ll want to take the time to configure these.


  • ID – ENU – English. you can do multiple languages for any given anything so keep that in mind if you want to do multilingual MPs.
  • Default – Default language I think? Also, If you split up your language pack definitions in visual studio like I do it will get angry if you put true on one and false on another. Or maybe its all of them…. I’m not sure, for my purposes false is grand and it will likely be the same for you.
  • DisplayString ElementID – This corresponds to those unique TypeID identifiers for rules and alerts and provides friendly display data for them in the console.
  • Remember that AlertParameter earlier in the Writeaction? This is where you can reference the variable in the KB for the console. Take notice that the AlertParameter1 begins at 1 and goes on to Alertparameter2, 3, 4 etc but the reference in the description begins at zero {0} and then {1}, {2}, etc. I’ve always thought it odd that one reference sequence begins at 1 and the other at 0. Just thought I’d point it out as something to keep in mind when trying to reference the correct variable.
  • KnowledgeArticle – This is the KB for the alert, pretty straight forward. check the documentation if you want more info.

That ends things for today. Stay tuned for part 2 where I will go over a Powershell based alert rule with the bonus of an example of alert suppression.

Part 2 – SCOM Visual Studio Authoring – VBScript and PwerShell Based Alert Rules Part 2

Site Index –