Blog
By Pete Zerger on 10/1/2009 11:32:14 PM • Rank (1446) • Views 1517
0

0

Have you every looked at an abstract class in OpsMgr and wondered "What management pack does this class come from? Every now and again I want to know where one of the many abstract classes is defined, often so I can go find it's relationships to other classes, and the answer is really easy to find if you can take one small step into the SDK.  (btw, see part 3 on SDK and class relationships). If you're not a programmer or a Powershell pro, hopefully this will gently push you to check it out.

Using the get-monitoringclass cmdlet, you can use a simple WHERE clause to retrieve the basic properties of a class. If all you have is the display name of the class, simply change .Name to .DisplayName in the one-liner below.

get-monitoringclass | where {$_.Name -eq 'Microsoft.Windows.InternetInformationServices.WebSite'}

If we add a pipeline and get-member cmdlet | get-member to the end of this one liner, we can see all the properties and methods of the SDK available to us (at least for a class anyway)

get-monitoringclass | where {$_.Name -eq 'Microsoft.Windows.InternetInformationServices.WebSite'} | get-member

Here's the output when we pass our class to get-member. If you just read this list, you'll get an idea of some of what's possible from the list. Amongst the methods, you see .GetManagementPack, which will show the management pack from whence this object class came. Now let's put it all together.

image

 
Simply wrap the first one-liner from above in brackets (), and add a .GetManagementPack() to the end, like so
 
(get-monitoringclass | where {$_.Name -eq 'Microsoft.Windows.InternetInformationServices.WebSite'}).GetManagementPack()

Here's the output. Notice the name of the MP in which the class is defined. 

image

So play around with some of those methods. In part 6, we'll take a few of those and wrap them in a foreach loop and see what we can do!

 

Previous Installments in the OpsMgr and Powershell and the SDK Series 

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: Recursive Enumeration

In the third installment, we examined the the .GetMonitoringRelationshipClasses() method to retrieve all the relationships for which a relationship is a source or target.

 Part 3 OpsMgr 2007 - Exploring Class Lineage in Powershell: Relationships

In the fourth installment, we put the two together in a quick script that outputs the derived classes and the relationships for which the class is a source or target. Since the output has grown increasingly verbose, this brief example sends the output to a text file.

OpsMgr 2007 - Exploring Class Lineage in Powershell: Part 4 – Recursive Enumeration of Classes and Relationships

In this installment, we put the two together in a quick script that outputs the derived classes and the relationships for which the class is a source or target. Since the output has grown increasingly verbose, this brief example sends the output to a text file.

 

 

Map Location


GPS Latitude: 0.00000 Longitude: 0.00000
Comments - Comment RSS


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

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