SCOM 2012 – Effective Configuration Viewer The PowerShell Way

A customer requested to have a capability to get an overview of the effective configured settings for rules / monitors and its values for Windows Computer objects. For some administrators browsing through the SCOM console is just too time consuming and / or too complicated. There are not many ways of providing a simple solution to satisfy this requirement, unless you know PowerShell – of course.

In PowerShell we have an interesting cmdlet called Export-SCOMEffectiveMonitoringConfiguration. This cmdlet let’s you calculate and export the current effective configuration for a monitored object. This sounds great, but there is a not so cool downside. The export file is a CSV separated by the “|” (pipe) delimiter which makes it a bit hard to handle it with certain cmdlets in PowerShell. As far I have seen, there is no way of changing the default delimiter nor the behavior of the cmdlet.

If you follow the syntax and export the CSV file from Export-SCOMEffectiveMonitoringConfiguration, the file looks like this JBOFHTRD (Just a Bunch OF Hard To Read Data)…

image

Of course you could use Excel to import the CSV and run some filter on the table, which is not my preferred choice of handling this kind of data. There must be a sexier way of doing it 🙂 . Ok, let’s code…

The first thing we do is, declaring two parameters like target computer name and the SCOM management server we would like to query. Then declare the path and array variable and if the path does not exist we will create the folder…

image

Next, we are going to connect to the SCOM management group, get the instance of the System.Computer class, which we specified as parameter. Since we have the computer instance, we need to fire off the Export-SCOMEffectiveMonitoringConfiguration cmdlet and retrieve the configuration for all objects of the specified instance and save it into a file…

image

Now, the core part of the script gets all the content from the previous generated file, then it iterates through each line, splitting the lines by the “|” (pipe) delimiter and adds the values to a PowerShell custom object. After each iteration, the object will be added to the defined array…

image

Note: The source configuration CSV output file contains about 90 columns, which are mostly empty. If you need to add more columns, because you have a lot of configured values for your monitor or rule, just extend the object with more properties. The next property would be like this…

image

Finally we are dumping the array to the Grid View….

image

In action, it looks like this…

image

Then, the magic moment happens. All the effective configuration for the server object server03.bigfirm.com will be shown in an easy, readable format…

image

The cool part just starts here. You are able to filter each column e.g. I just want to see which monitors or rules are enabled, click Add Criteria and select the column Enabled contains True…

image

You are even capable of searching any term and it will filter the view accordingly…

image

That’s the real way of getting the effective configuration for a monitored computer. The requirements for the script are simple, you just need to have PowerShell and the OperationsManager PowerShell module installed on your client.

There is famous song from Frank Sinatra “I did it my (PowerShell) way”…

Download the script from TechNet Gallery

26 Comments

  1. Hello Stefan, thanks for posting very useful
    Can you tell me please does his cmdlet (I am still on SCOM 2007 R2) also get the values once any overrides have been taken into account? as this was always a bit of an issue
    for example I have a monitor that when created has a default alert severity of warning. The MP in deployed and at some future date this monitor is overridden for one of the computer and the severity is set to critical. If I run the above will it show the value for the above as warning (e.g. the setting from the original MP configuration or will it show critical to reflect that is the live setting for this on the agent?

    I would be grateful if you could let me know the answer this this please 🙂
    Jo

    • Hi Jo

      It will show the effective setting of critical for the monitor. Be aware that the script uses a cmdlet for SCOM 2012. You will also see if e.g. a monitor was disabled in the “original” MP and it was enabled at a later point in time, the Setting will show up as enabled.

      Cheers,

      Stefan

  2. Hi Stefan,
    Thanks for the script, this is a great post :))
    There is custom configuration for rule/monitor the name doesn’t look friendly, for example “MomUIGeneratedRule6d9a17bc90ef492…”. Is that possible to grab the friendly name of the rule/monitor?

  3. Numerous problems with Export-SCOMEffectiveMonitoringConfiguration. First were the sql errors due to duplicate writeactions in the cluster MP.
    http://scom.dnfconsulting.net/export-scomeffecticemonitoringconfiguration/
    that took me many days to find and i ended up fixing it by excluding certain IDs for win 2008 since we use 2008 R2 and i know this woul dnot hurt my data. If i just added top1 as recommended the exported config would be incomplete. Now that its all working w/out error I just get incomplete data from Export-SCOMEffectiveMonitoringConfiguration. For example i run that off a group of web servers. One of them will produce a file half the size as the rest whihc is missing most all monitors. If i check manually via the console gui, neither have failed workflows and they both show same things monitored.

  4. Pingback: Rules and Monitors on Your Dashboard, Part 1 | SCOM by THOM

  5. Pingback: Comment suivre l'évolution de la configuration des agents Opérations Manager ? - FrenchOpsMgrPFETeam - Site Home - TechNet Blogs

  6. sorry..I’m re-phrasing the question. In health explorer, I can see the list of monitors and rules linked to the host, along with that the management pack name as well (in monitor/rule propeties). Using powershell query, Can I get the management pack list for an agent which are actually applied on the host ?

  7. Hi..thanks for the answer. When I checked the list of management packs ‘effective’ on a host, it is very few in number. (Checked it from Healthexplorer->Monitor->Properties->MP name). List for a sample server is given below.
    ————————————————————–
    operation Manager APM infrasturture
    Windows server 2012 operating system(monitoring)
    Microsoft audit collection service
    Microsoft System Center Advisor Internal
    system center core monitoring
    Exchange server 2010
    Network Management – core monitoring
    Microsoft Forefront Endpoint Protection Application
    system center core monitoring
    Windows core library
    Windows server operating system library
    Health Library
    —————————————————————–
    But when I check the list of MPs downloaded on the host (from \\server\c$\Program Files\Microsoft Monitoring Agent\Agent\Health Service State\Management Packs) list is huge and I can’t find many in health explorer as effective monitoring configuration.

    ‘Export-SCOMEffectiveMonitoringConfiguration’ cmdlet shows the list of monitors/rules and details along with description, but management pack name corresponding to these monitors/ruls is missing in report.

    So what I’m looking here is to get the list of ‘effective’ management pack names which are configured on hosts.Since this information is needed for some analysis on 100s of servers, checking if any powershell queries are available. Suggestions in this matter will be helpful. Many thanks.

  8. Satheesh,
    Not all management packs contain monitors and/or rules so the list of MPs won’t be directly proportional to the number of monitors that you might see in Health Explorer. So… keep that in mind.

  9. Hi Stefan,

    This is a great script, I haven’t found anything else that will show me all the rules, monitors AND overrides applied to a computer in a single view.

    I have the same problem as Amy though – I have a lot of custom rules and monitors that are displayed as “MomUIGeneratedRule6d9a17bc90ef492…”. Is it possible to display the friendly name of the rule/monitor? I know it’s possible with Get-SCOMRule | where {$_.Name -eq “MomUIGeneratedRule6d9a17bc90ef492…}

    • First I want to say, Great script Stefan, as always! I learn something new every time I visit your site.

      Lee,
      I modified Stefan’s script a bit to add the display name of the rules/monitors. The lines I added are all commented below
      $count = 0 # Add a counter so we can get a header column for Display Name
      ForEach ($line in $lines) {

      ForEach ($field in $line)

      {
      $Values = $field.Split(‘|’)
      if ($Values[7] -eq ‘Rule’) { # This is a rule, not a monitor, so we need to run Get-ScomRule to find the DisplayName
      if ($Values[2] -ne $null) # Sometimes we hit a row that doesn’t have a rule name (like the headers) – skip it
      {
      $ObjectDisplayName = (Get-SCOMRule -Name $Values[2]).DisplayName # Use the Get-SCOMRule cmdlet, pass the name from the line above, and return the .DisplayName property
      }
      } else { # This is a monitor, do the needful
      if ($Values[2] -ne $null) # Sometimes we hit a row that doesn’t have a monitor name (like the headers) – skip it
      {
      $ObjectDisplayName = (Get-SCOMMonitor -Name $Values[2]).DisplayName # Use the Get-SCOMMonitor cmdlet, pass the name from the line above, and return the .DisplayName property
      }
      }
      $object = New-Object –TypeName PSObject
      $object | Add-Member –MemberType NoteProperty –Name Class –Value $Values[0].Replace(‘”‘,”)
      $object | Add-Member –MemberType NoteProperty –Name InstanceName –Value $Values[1]
      $object | Add-Member –MemberType NoteProperty –Name RuleMonitor –Value $Values[2]
      if ($count -eq 0) # $count is 0, so this must be the header row – add a ‘Display Name’ header column
      {
      $object | Add-Member –MemberType NoteProperty –Name DisplayName –Value ‘Display Name’
      } else {
      if ($ObjectDisplayName -ne $null) { # If the query from lines 45 or 50 returned a blank, we’ll bypass the next command
      $object | Add-Member –MemberType NoteProperty –Name DisplayName –Value $ObjectDisplayName # We got a display name! Add it to the object, so it can go to the array
      }
      }
      $object | Add-Member –MemberType NoteProperty –Name Enabled –Value $Values[3]
      $object | Add-Member –MemberType NoteProperty –Name GeneratesAlert –Value $Values[4]
      $object | Add-Member –MemberType NoteProperty –Name AlertSeverity –Value $Values[5]
      $object | Add-Member –MemberType NoteProperty –Name AlertPriority –Value $Values[6]
      $object | Add-Member –MemberType NoteProperty –Name AlertType –Value $Values[7]
      $object | Add-Member –MemberType NoteProperty –Name AlertDescription –Value $Values[8]
      $object | Add-Member –MemberType NoteProperty –Name Overriden –Value $Values[9]
      $object | Add-Member –MemberType NoteProperty –Name Parameter1 –Value $Values[10]
      $object | Add-Member –MemberType NoteProperty –Name DefaultValue1 –Value $Values[11]
      $object | Add-Member –MemberType NoteProperty –Name EffectiveValue1 –Value $Values[12]
      $object | Add-Member –MemberType NoteProperty –Name Parameter2 –Value $Values[13]
      $object | Add-Member –MemberType NoteProperty –Name DefaultValue2 –Value $Values[14]
      $object | Add-Member –MemberType NoteProperty –Name EffectiveValue2 –Value $Values[15]
      $object | Add-Member –MemberType NoteProperty –Name Parameter3 –Value $Values[16]
      $object | Add-Member –MemberType NoteProperty –Name DefaultValue3 –Value $Values[17]
      $object | Add-Member –MemberType NoteProperty –Name EffectiveValue3 –Value $Values[18]
      $object | Add-Member –MemberType NoteProperty –Name Parameter4 –Value $Values[19]
      $object | Add-Member –MemberType NoteProperty –Name DefaultValue4 –Value $Values[20]
      $object | Add-Member –MemberType NoteProperty –Name EffectiveValue4 –Value $Values[21]
      $array.Add($object)
      $count++
      }
      }

      Hope this helps. If anyone has any suggestions for improvement, please speak up.

      Also, Stefan, have you tested this with an ArrayList for the $array variable? I’m curious if there could be performance gains.

      Cheers,
      Ron

  10. The script doesn’t give all the filesystems which are getting monitored, it just displays the first FS when we pull the effective configuration..any suggestions on how can we fix this..

    Thanks,
    Kushagra

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