Blog
By Pete Zerger on 9/25/2009 2:43:55 AM • Rank (994) • Views 1184
0

0

In our initial foray into the OpsMgr SDK in Powershell, we examined the .GetDerivedMonitoringClasses() method to explore the lineage of classes in your OpsMgr management group.

Part 1 - OpsMgr 2007: Exploring Class Lineage in Powershell

In the second installment, we examined how easy it was to create a function to enumerate the lineage of every class in OpsMgr recursively.

Part 2 - OpsMgr 2007 - Exploring Class Lineage in Powershell: Part 2 – Recursive Enumeration

In this installment, we're going to look at the .GetMonitoringRelationshipClasses() method to explore the relationships between classes in Operations  Manager. Given a target class, this method returns all the relationships for which the target class is either the source or the target. Again nothing fancy, but this simple function does provide an easy way to enumerate relationships without opening multiple MPs in the MP Viewer or Authoring console.

From here, we can extend this function to enumerate all child classes and their relationships recursively…more on that tomorrow. Let's execute this function and have a look at the output. This sample will return the relationships of the SQL DB Engine class…you'll notice as in previous examples we pass the Name, not DisplayName.

Sample Script (save with .ps1 extension run from OpsMgr Command Shell prompt)

   1:   
   2:  function GetRelationships 
   3:  {param ($Class)
   4:   
   5:  (get-monitoringclass | where {$_.Name -eq "$Class"}).GetMonitoringRelationshipClasses()|fl DisplayName, Description
   6:  }
   7:   
   8:  #call the function specifying target class in quotes
   9:  GetRelationships "Microsoft.SQLServer.DBEngine"

Sample Output

And there it is. We see the hosting relationships between DB Engine (source) and SQL Database (target). No need to return much more than this to get the idea. If you want to see the less friendly name, add Name to the list of fields by DisplayName in the function.

image

 

 

 

 

 

Tomorrow, we'll dress this up a bit to return a list of all relationships for all classes.

In parts 5 and beyond, we'll look at combining these two functions with some  formatting on the output to create some really useful reference material.

Comments - Comment RSS


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

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