Home > Operations Manager 2012 > Exploring your discovered inventory using the OpsMgr 2012 Sp1 Command Shell (part 2)

Exploring your discovered inventory using the OpsMgr 2012 Sp1 Command Shell (part 2)

This is an update to an article series MVP Pete Zerger wrote for Operations Manager 2007. (Original Post)

Using the get-SCOMClass cmdlet we are able to retrieve a list of the discovery objects classes and export them to a csv file with the headers DisplayName, Name and Description like so:

Get-SCOMClass | select-object DisplayName, Name, Description | export-csv –path c:\temp\classes.csv

So now you have a long list of discovery object classes that OpsMgr knows about in a text file, big deal, how does this information help Joe OpsMgr Admin? Well armed with this information about the object classes you could find out for example what SQL 2008 Databases your OpsMgr environment is monitoring by utilizing an additional cmdlet called Get-SCOMClassInstance:

Get-SCOMClass –name “Microsoft.SQLServer.2008.Database” | Get-SCOMClassInstance

get-scomclass -name Microsoft.SQLServer.2008.Database Get-SCOMClassInstance

Now we’re getting somewhere. Wait hold on I see the same databases listed twice, what is going on here? The default output of the Get-SCOMClassInstance is what is shown in the screenshot but there is still a boatload of information that is available. To find out what is available to the pipeline, pipe the line above to Get-Member to show a list of properties that are available.

Get-SCOMClass –name “Microsoft.SQLServer.2008.Database” | Get-SCOMClassInstance | Get-Member

I’ve scrolled down to only show the properties.


The property we need to use to find out the server name of the database is the Path Property. Let’s go ahead and plan on sorting this data output so we can see it by server then the databases in order as well. so we will use the Sort-Object on the Path then Name, and then Pipe the output to Format-Table Path, Name like so:

Get-SCOMClass –name “Microsoft.SQLServer.2008.Database” | Get-SCOMClassInstance | Sort-Object Path, Name| FT Path, Name


By utilizing the cmdlet Get-SCOMClass to fetch a specific class, then using the cmdlet Get-SCOMClassInstance you could easily provide at a glance reports, or script automated reports to be emailed out to other administrative personnel or application stakeholders.

Disclaimer: Always test ideas you have for PowerShell in a lab environment first to make sure you understand the load it could put on your OpsMgr infrastructure.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: