Freigeben über


How is the path property for a SCOM class instance created?

Recently a colleague asked me about a blog post I wrote some time ago regarding calculating GUIDs of SCOM objects: https://blogs.technet.microsoft.com/dirkbri/2015/06/11/how-are-guids-in-scom-and-scsm-calculated/

He wanted to calculate the GUID for a specific logical disk. Per the post, this requires the following data to be available to calculate the GUID of the specific instance:

  • GUID (ID) of the class of the object (= class instance)
  • GUID and values of all Key properties in the path in the right order

The first requirement is easy to fulfill. We know the object, so we can simply get the related class and its ID, preferred via PowerShell.

But the second requirement might be a bit trickier. So I thought it might be useful for a bigger audience to shed some light on the property "Path" and how it is built. That is the purpose of this post.

General information about classes, inheritance and all the rest

This post does not cover the basic terms. Please have a look at this excellent article for more details:
https://social.technet.microsoft.com/wiki/contents/articles/14256.operations-manager-management-pack-authoring-classes-and-relationships.aspx

How do I get the key property of a class and its Id?

This can be easily accomplished via the OperationsManager PowerShell module. Retrieve the class instance and use the property "PropertyCollection" to search for any key property:
keypath-01
That gives us the key property, its name and its ID.

How is the path property of an object built?

The path of any SCOM object is unique within the Management Group and is built by combining all key properties of the object itself and of all key properties of its hosting class (if hosted).

In general, you could write a path property like this:
\\Key property of the hosting class[\Key property of any subordinate hosting classes]\Key property of the target class

Let me give you an example for a SQL database:
For a database named msdb on a server called server1 with a SQL instance of SQLDEMO, the path would be:
\\Server1.my.domain\SQLDEMO\msdb

How do you get the the right key properties? You have to go up all the way in the class tree and check, if this class has a key property:
The class of the SQL database is e.g. MICROSOFT.SQLSERVER.DATABASE. This class has a key property of DATABASENAME.
The class MICROSOFT.SQLSERVER.DATABASE is derived from SYSTEM.DATABASE, which is derived from SYSTEM.APPLICATIONCOMPONENT and so on and so on.

That can be quite challenging and time consuming...

Custom function to retrieve the required key properties

As I hate to do things manually I wrote a short, quick and quite dirty PowerShell function get-scomkeypropertiesforclass which helps me accomplishing my goal. You can download it here. The function takes a class name as an input and

  • calculates the correct path of key properties for any instance of this class
  • it returns all key property names and their IDs, which can be used

Let’s see the function in action for the class MICROSOFT.SQLSERVER.DATABASE:
keypath-03

You can see as the result the correct path properties.

It has also a switch called “PrintDetails” which gives us more details about the object structure itself:
keypath-04
And, as a small benefit, it contains another switch called “ReturnKeyPropertyObjects” which returns all key property names and their IDs as custom PowerShell objects:

keypath-02

 

Example: Calculating the GUID of a Windows 2012 logical disk instance

You can use this knowledge to calculate any kind of GUID, e.g. of a specific logical disk instance:

1. Step: Get the values by using the OpsMgr Shell and my little function
keypath-07

2. Step: Copy these values to SQL and calculate the GUID

keypath-06

 

I hope, that this post shed some light on the path property of each SCOM class instance and maybe the function might be helpful to you :)