SCOM – Populate Attributes Through PowerShell

This time I would like to show a cool idea about modifying class instance properties. In SCOM we usually use registry or WMI discoveries to populate attributes. These attributes are used for dynamic groups or maybe just to append some more information to the class instance.

Imagine you are using a registry discovery for populating the class instance attributes / properties. This works great and if you are able to set all the information into the monitored computers registry this is perfect. Now let’s assume you have SCOM monitored computers in your DMZ and you want to set those registry keys which you need to fill your attributes and therefore to build your dynamic groups in SCOM.

Here we run in a couple of problems:

  • How are you keeping your registry values updated on servers in the DMZ?
  • What permissions / credentials are you going to use to write to the DMZ servers registry?
  • There might be all kind of OS versions and therefore you are limited with some technologies like PowerShell (not installed), WMI issues (x86 / x64 Bit).
  • etc.

If we think about it and isolate the problem, then we would just need to find a way to modify the attributes in SCOM directly without depending on the discovery. But how are we going to do this?

For this example I created just a custom class in VSAE which inherits form Microsoft.Windows.Computer. Then I added a property called CustomValue…

image

Next, I created a registry discovery which discovers registry values for all Windows computers….

image

If you import the management pack and go to Discovered Inventory you will see something like this…

image

As you can see the Custom Value is empty, because the registry discovery is configured for HLKM\Software\Custom\CustomValue and since there is no registry key on those servers the value will stay empty. Let’s assume SOFS1.fabric.lab.itnetx.ch and CA01.services.lab.itnetx.ch  are DMZ servers and we need to fill the Custom Value property.

This sample script will add some test values to the Custom Value property…

image

…and after you run the example…

image

The PowerShell script I have written is just a sample code to show, how you can populate the custom attributes. You could easily extend this to use Orchestrator or SMA to run on a schedule. Of course instead of a hashtable you could retrieve the values from a database e.g. CMDB etc. all this should not be a problem at all…

I have uploaded the sample management pack VSAE project and PowerShell script to OneDrive. I hope you find this also as cool as I do :).

4 Comments

  1. Stefan,
    This is a great post, but I’m having trouble and I’m not sure where I’m tripping up at. When I get to the .commit() line, I’m being told there is no method for my object. When I look at it, it’s correct, there is no commit method. My object type is “Microsoft.EnterpriseManagement.Common.EnterpriseManagementSimpleObject” and the methods available are Equals, GetHashCode, GetType, Reconnect, SetToDefault, and ToString. That’s it. No Commit.

    The properties are from an MP that I created a long time ago in 2007 and brought over to 2012. The properties are done the same as you describe. They were created by extending the computer class, then discovered via a simple discovery. I’d like to change a value of a server that’s currently offline, but I can’t commit the changes.

    Any ideas?

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s