Blog
By Pete Zerger on 9/23/2009 7:17:15 PM • Rank (1952) • Views 2045
0

0

In yesterday's example (HERE), we looked at the a simple Powershell example using the .GetDerivedMonitoringClasses() method from the SDK. In that example, given an object class from OpsMgr (e.g. system.entity) the script would return the derived classes of system.entity – those classes for which system.entity is the base class and their derived classes (grandchildren we might call them).

But what if you wanted to see the entire lineage - every class in OpsMgr and all classes derived from them?

I thought that would be interesting for me to see.  A single dump of all this data so I have less need to open MPs in MP Viewer or the Authoring console. Here's a simple Powershell function that will do just that.

WARNING: The sample here targets System.Entity (THE BASE CLASS) in Operations Manager. Output is pretty verbose. Runs fine in my lab VM, but I suggest you confine this one to the lab.

 

 
Sample Script (save with .ps1 extension run from OpsMgr Command Shell prompt. Replace system.entity on last line with the class of your choice.)
   1:  function DerivedClasses ($TargetClass){
   2:   
   3:  $Class = $TargetClass
   4:   
   5:  foreach ($baseclass in $baseclasses) {
   6:   
   7:  $DerivedClasses = (get-monitoringclass | where {$_.Name -eq "$Class"}).GetDerivedMonitoringClasses()
   8:   
   9:  foreach ($DerivedClass in $DerivedClasses) {
  10:   
  11:  Write-Host " "
  12:  Write-Host "The following classes are derived from " $DerivedClass.DisplayName ":"
  13:  (get-monitoringclass -Name $DerivedClass ).GetDerivedMonitoringClasses() | select DisplayName, Name 
  14:   
  15:  #Here, we call the DerivedClasses function for the each of the child classes recursively
  16:  DerivedClasses $DerivedClass
  17:  }
  18:  }
  19:  }
  20:   
  21:  #Call the function and pass in the Name (NOT the Display Name) of the desired base class.
  22:  DerivedClasses 'system.entity'

 

Sample Output

 

As you can probably guess, enumeration of all classes results in a lot of output. Here's a small snippet of the output. If there's interest, in a future we can discuss formatting output to a spreadsheet or other proper reporting format.

image

Map Location


GPS Latitude: 0.00000 Longitude: 0.00000
Comments - Comment RSS


Who Viewed
Who Reviewed
Categories
Related Pages
Shortened URL
http://tinyurl.com/mn9dee

Top Contributors
Featured Members
Pete Zerger
Points: 65622
Level: System Center Expert
Tommy Gunn
Points: 42748
Level: System Center Expert
Simon Skinner
Points: 40804
Level: System Center Expert
Stefan Koell
Points: 28999
Level: System Center Expert
Andreas Zuckerhut
Points: 27734
Level: System Center Expert