|
|
 
0 |
Here's a quick-and-dirty Powershell snippet for OpsMgr I was playing with you might find useful for exploring class lineage in OpsMgr. Given a target class, this bit of Powershell will present the classes based on that class you add to the $Class variable
For example, given System.Entity (the base class in OpsMgr):
- Script will return child classes of System.Entity, which are System.PhysicalEntity, System.LogicalEntity and Microsoft.Unix.SupportedAgent (R2 with X-Plat only).
- Then returns to the screen all classes using each of these as their base class. In other words, all classes derived from Physical and Logical Entity.
Nothing fancy, but does provide an easy way to enumerate classes without opening multiple MPs in the MP Viewer or Authoring console. A bit of playing and we could create a function to return all child classes and their children recursively…I will have to play around a bit longer for that when time allows.
Sample Script (save with .ps1 extension run from OpsMgr Command Shell prompt)
1: #Replace system.entity with the class of your choice
2: $Class = 'system.entity'
3:
4: foreach ($baseclass in $baseclasses) { 5:
6: $DerivedClasses = (get-monitoringclass | where {$_.Name -eq "$Class"}).GetDerivedMonitoringClasses() 7:
8: foreach ($DerivedClass in $DerivedClasses) { 9: Write-Host " "
10: Write-Host "Derived classes based on " $DerivedClass.DisplayName "(" $DerivedClass.Name ")" 11: Write-Host "The following classes are derived from " $DerivedClass.DisplayName ":"
12: (get-monitoringclass -Name $DerivedClass ).GetDerivedMonitoringClasses() | select DisplayName, Name
13: }
14: }
Sample Output
