SCOM 2012–What’s in my group?

How do you tell what is actually contained within a group?  Looking at a group in the console only reveals the objects that have been added to that group, however, it does not reveal all of the objects that are contained within each of those visible entities.  For example, when you create an override for a Logical Disk monitor and point it at a group that contains Windows Computers, how do you know your Logical Disk is in fact in that group?

$Groups = Get-SCOMgroup
$Group = Get-SCOMGroup -DisplayName “SQL Computers”
$Group.GetRelatedMonitoringObjects()

HealthState     InMaintenanceMode  DisplayName
———–     —————–  ———–
Success               False        TSTWAPDB.tailspintoys.lab
Error                 False        TSTOM02.tailspintoys.lab
Success               False        TSTCM01.tailspintoys.lab
Success               False        TSTSQL01.tailspintoys.lab
Success               False        tstsql02.tailspintoys.lab
Success               False        TSTSQL03.tailspintoys.lab

Let’s say we want to apply some overrides to this group.  How would we know exactly what is going to be impacted?

$Group.GetRelatedMonitoringObjects(‘recursive’)

This generates the whole list of objects contained within the group along with their HealthState, InMaintenanceMode and DisplayName information (what PowerShell decides to display to the screen).  I want to see what type of object each of these really are and not just their DisplayNames and HealthState information.  Each of the contained objects has various pieces of information which includes the GUID for the class type.

$Objs = $Group.GetRelatedMonitoringObjects(‘recursive’)
$Objs[0].LeastDerivedNonAbstractManagementPackClassId

Guid
—-
10c1c7f7-ba0f-5f9b-c74a-79a891170934

I need to resolve the GUID to the actual class name.  Putting it all together yields:

$Groups = Get-SCOMGroup
$Group = Get-SCOMGroup -DisplayName “SQL Computers”
$Class = Get-SCOMClass
$Objs = $Group.GetRelatedMonitoringObjects(‘Recursive’)
Foreach($Obj in $Objs) {
$Obj.DisplayName + “,” +
$Obj.Path + “,” +
($Class | where{$_.Id.GUID -eq $Obj.LeastDerivedNonAbstractManagementPackClassId.GUID}).DisplayName
}

With that, we can manipulate the data anyway we want.  I typically dump the data out to a CSV file as it can be easier to search and manipulate with something like Excel depending on how much data you are working with.

Why is this useful?  Say you have overrides targeted at a group but you are still not getting the desired effect.  In that situation, it’s nice to ensure the object you are truly trying to target is in fact contained within the group.

Additionally, it is nice from an authoring perspective when you are trying to traverse relationships and are authoring complex groups using the <Contains> and <Contained> tags.  In complex scenarios sometimes <Contains> and <Contained> are embedded within each other.  In those situations, this kind of script comes in very handy.

This is also useful when looking directly at a specific instance rather than a group.  The GetRelatedMonitoringObjects along with recursive can be used to explore any object within a SCOM environment.  For example, here is how to look at all of the discovered objects on a specific machine:

$Machine = Get-SCOMClassInstance -Class (Get-SCOMClass -DisplayName “Windows Computer”)
$Machine[0].GetRelatedMonitoringObjects(‘Recursive’)

This shows all of the objects associated with this specific machine including items such as the Logical Disks and other objects that are related to this Windows Computer.

Leave a Reply