none
How to get overrides that are in a particular management pack for a group

    Question

  • I have this working in SCOM 2007 R2, but overrides changed a lot in SCOM 2012 (I am at SP1).

    Background:  I have manually created overrides to monitors and rules in various sealed management packs.  The overrides are saved to an unsealed management pack.  The overrides are for a group that is in a sealed management pack.

    1) How can I use powershell to get the overrides that are within a management pack?

    2) How can I determine through powershell which group name is associated with the override?

    Here is how I did it for SCOM 2007R2 with comments about trying to do it in SCOM 2012:

    $AllGroups = get-monitoringobject #this is a painfully slow way to get all the groups in the connected management group.

    # in scom 2012, this is much easier with the get-scomgroup commandlet

    $matchedMP = get-managementpack|where {$_.Name -match $MPwithGroupsPattern}

    # In SCOM 2012, this becomes get-scommanagementpack, but pipe to where is still there. 

    #Incidently the regex pattern match feature of get-scommanagementpack's -Name and -DisplayName options does not work with \. in the pattern

    $MPfamilyOverRides = $matchedMP |get-override

    #in SCOM 2012, this is dramatically changed.  The Get-scomoverride does not accept input from a management pack.

    #this is the challege, how to get the list of overrides that are in a particular management pack.

    foreach ($oneoverride in $MPfamilyOverRides) {

        $groupId = ($oneoverride.Context).Id.Guid

        $groupName =""

        foreach ($OneGroup in $AllGroups) {
            if ($OneGroup.Id -eq $groupId) {
                $groupName = $OneGroup.PathName
       }

        $oneoverride  # I really do something else with the override information, but this gets the main point across

        $groupname

      }


    Ted

    Thursday, May 23, 2013 2:46 PM

Answers

  • Hi Ted,

    You can use the GetOverrides() method on the management pack object returned by Get-SCOMManagementPack, so that line becomes:

    $MPfamilyOverRides = $matchedMP.GetOverrides() #assuming $matchedMP is a single MP here, not an array of MPs

    Taking a completely different approach, you could make use of the underlying SDK methods to get the overrides for each group directly, without having to go via the management packs:

    $groupId = $myGroup.Id
    (Get-SCOMManagementGroup).Overrides.GetOverrides("ContextId = $groupId")

    Hope this helps,

    Richard


    Richard Benwell www.squaredup.com


    Friday, May 24, 2013 10:05 PM
  • Bingo!!!

    Your original suggestions hit the mark.

    $groupId = $myGroup.Id
    (Get-SCOMManagementGroup).Overrides.GetOverrides("ContextId = $groupId")

    This allows me to get the overrides that are assigned to a computer group or other type of group.

    Thanks, for everyone's help.

    Ted


    Ted

    Tuesday, May 28, 2013 7:03 PM

All replies

  • Hi Ted,

    You can use the GetOverrides() method on the management pack object returned by Get-SCOMManagementPack, so that line becomes:

    $MPfamilyOverRides = $matchedMP.GetOverrides() #assuming $matchedMP is a single MP here, not an array of MPs

    Taking a completely different approach, you could make use of the underlying SDK methods to get the overrides for each group directly, without having to go via the management packs:

    $groupId = $myGroup.Id
    (Get-SCOMManagementGroup).Overrides.GetOverrides("ContextId = $groupId")

    Hope this helps,

    Richard


    Richard Benwell www.squaredup.com


    Friday, May 24, 2013 10:05 PM
  • Thanks, the GetOverrides() method does provide a way to get the overrides from a particular managemnet pack.  That does replace the  $matchedMP |get-override
    .

    Your second suggestion does address how to get the overrides for a whole management group, but unfortunately, I am looking for overrides assigned to a particular computer (or other type) of group within the management group.

    We need this because we assign overrides to computer groups as a way to get the same settings applied to the member computers.

     


    Ted

    Tuesday, May 28, 2013 4:26 PM
  • Would the Export-SCOMEffectiveMonitoringConfiguration cmdlet be of any help here?

    Marcin Jastrzębski http://blogs.technet.com/marcin_jastrzebski

    Tuesday, May 28, 2013 5:41 PM
  • I appreciate the suggestion.

    It looks like that command produces the monitors, rules and overrides associated with a monitoringObject.  Unfortunately, I cannot assume that the groups contain monitored objects so it is probably not going to work with that command.  In addition, this provides whatever is associated with a particular monitored object without regard to where it came from (i.e. group or management pack).


    Ted

    Tuesday, May 28, 2013 5:53 PM
  • My second suggestion above gets the overrides that target a particular group (using the "ContextId = $groupId" criteria string) - the filtering is done on the server side so is much more efficient. If you know the groups in advance, you can use that method to get the overrides targetting each group. Or am I misunderstanding your requirement?


    Richard Benwell www.squaredup.com


    • Edited by Richard Benwell Tuesday, May 28, 2013 6:47 PM Fix weird font size
    Tuesday, May 28, 2013 6:46 PM
  • Bingo!!!

    Your original suggestions hit the mark.

    $groupId = $myGroup.Id
    (Get-SCOMManagementGroup).Overrides.GetOverrides("ContextId = $groupId")

    This allows me to get the overrides that are assigned to a computer group or other type of group.

    Thanks, for everyone's help.

    Ted


    Ted

    Tuesday, May 28, 2013 7:03 PM