Monday, February 8, 2010

Basic OpsMgr concepts - Classes and Objects

One abstract OpsMgr concept people generally battle with is distinguishing the difference between an object and a class.

In this post I'll use the following two as examples:

Object: Computer01.Pretend.com
Class: Microsoft.Windows.Computer

To see an example of this, navigate to the "Discovered Inventory" pane in OpsMgr. If you change the scope to "Windows Computer", you will (in my hypothetical example) see Computer01 listed. This means that the OBJECT Computer01 is of CLASS type Windows Computer.

To demonstrate this, let's look at two powershell CMDlets: get-monitoringclass and get-monitoring-object:

$class = get-monitoringclass -name "Microsoft.Windows.Computer"


This will assign the variable $class with the object for the class "Microsoft Windows Computer."

If we now wish to get a list of all monitoring objects contained within that class, we need to use get-monitoringobject:

$class  get-monitoringobject


As you can see, this supports pipeline usage - we take our $class variable and pipe it to get-monitoringobject. This then iterates through the class returning all its objects. We can then further format the data by using Select-Object to select the fields we're wanting to view. Additionally, if we're just wanting a total, we can pipe it to "measure-object" to get an object count.

What we've done here is mimicked the "Discovered Inventory" view in the GUI. This is very helpful if we're needing certain objects for something.

If you require assistance or would like a particular topic covered, be sure to leave a comment on a post.

Next up: Using "criteria" to search instead of Where-Object

No comments:

Post a Comment