OpsMgr 2007: Exploring your discovered inventory with the Command Shell
In the previous Powershell Tip, you can see that it’s quite easy to enumerate the object classes present in your Operations Manager 2007 environment. You may be surprised to learn it’s equally simple to take this example one step further to enumerate the discovered instances of a given object class.
Using a similar one-liner to the previous tip, we can use get-monitoringclass cmdlet to retrieve a list of the discovered object classes, like so:
get-monitoringclass | select-object DisplayName, Name, Description | export-csv -path c:\classes.csv
We can then find the Name column in this output (not to be confused with DisplayName) to retrieve a list of discovered instances of the object class of our choice by passing output of the get-monitoringclass cmdlet for a single class to the get-monitoringobject cmdlet, as illustrated for the ‘SQL 2005 DB’ object class below:
get-monitoringclass -name “Microsoft.SQLServer.2005.Database” | get-monitoringobject
And using the format-table cmdlet demonstrated in several past examples, we can filter and format results in a neatly organized tabular format, so display only the database DisplayName (e.g. OperationsManager) and PathName, which represents the server and SQL instance that hosts the database.
get-monitoringclass -name “Microsoft.SQLServer.2005.Database” | get-monitoringobject | ft DisplayName, PathName
The resulting output of the PathName is a bit messy, but you can spot the host server and SQL instance name (MSSQLSERVER is the default SQL instance).
DisplayName PathName
———– ——–
msdb OPSMGR.contoso.com%003bMSSQLSERVER%003amsdb
In the next installment, we’ll take a short look at a special object class…groups

July 12th, 2008 at 12:43 am
[…] OpsMgr 2007: Exploring your discovered inventory with the Command Shell […]