locked
How to get overrides that are in a particular management pack for a group RRS feed

  • 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


    • Edited by Richard Benwell Friday, May 24, 2013 10:10 PM
    • Marked as answer by Cloud_TS Tuesday, June 4, 2013 1:50 AM
    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

    • Marked as answer by Cloud_TS Tuesday, June 4, 2013 1:50 AM
    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


    • Edited by Richard Benwell Friday, May 24, 2013 10:10 PM
    • Marked as answer by Cloud_TS Tuesday, June 4, 2013 1:50 AM
    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

    • Marked as answer by Cloud_TS Tuesday, June 4, 2013 1:50 AM
    Tuesday, May 28, 2013 7:03 PM
  • For some reason i am not able to extract the overrides for groups...

    (Get-SCOMManagementGroup).Overrides.GetOverrides("ContextId = $groupId")
    
    Cannot convert argument "criteria", with value: "ContextId = 8ebec9b8-b0d8-ac73-2669-5b12bd282372", for "GetOverrides"
    to type "Microsoft.EnterpriseManagement.Configuration.ManagementPackOverrideCriteria": "Cannot convert value
    "ContextId = 8ebec9b8-b0d8-ac73-2669-5b12bd282372" to type
    "Microsoft.EnterpriseManagement.Configuration.ManagementPackOverrideCriteria". Error: "The criteria used for the query
    has a character or keyword that is not valid. The following parse error was returned: Parse error before ebec9b8""
    At line:1 char:1
    + (Get-SCOMManagementGroup).Overrides.GetOverrides("ContextId = $groupId")
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodException
        + FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument






    Thursday, May 26, 2016 1:23 PM
  • (Get-SCOMManagementGroup).Overrides.GetOverrides("ContextId = '$($groupId)'")

    should work.

    • Proposed as answer by Tommy van E Monday, May 30, 2016 11:58 AM
    Friday, May 27, 2016 2:48 PM
  • (Get-SCOMManagementGroup).Overrides.GetOverrides("ContextId = '$($groupId)'")

    should work.

    Thanks, that works :)
    Monday, May 30, 2016 11:58 AM
  • I've been working on a script to get the overrides for groups, including support for child groups and subscriptions.

    So the result of this script is a list of groups that do not contain overrides, subgroups or are part of subscriptions. In other words; groups that are not used anywhere? 

    Feel free to optimize.

    ### Get subscriptions
    
    $subgroups = @()
    
    $subs = Get-SCOMNotificationSubscription | Select-Object Configuration
    
    foreach ($sub in $subs) {
    $sgroups = $sub.Configuration.MonitoringObjectGroupIds | Select-Object Guid
       foreach ($sgroup in $sgroups) {
             $subgroups += $sgroup.Guid
       }
    }
    
    ### Get groups and associated overrides
    
    $groups = Get-SCOMGroup
    
    $preresults = @()
    
    foreach($group in $groups){
    
        $overrides = @()
        $groupid = @()
        $childs = @()
    
        $groupid = $group.Id
    
        ### Get the actual overrides
        $overrides = (Get-SCOMManagementGroup).Overrides.GetOverrides("ContextId = '$($groupId)'")
    
            if(!$overrides){
    
                ### Exclude groups with childs (sub-groups)
                $childs = $group.GetChildMonitoringObjectGroups()
    
                    if(!$childs){
    
                    $override = New-Object PSObject
    
                    $override | Add-Member -type NoteProperty -Name 'ID' -Value "$($group.Id)"
                    $override | Add-Member -type NoteProperty -Name 'DN' -Value "$($group.DisplayName)"
    
                    $preresults += $override
            }
        }
    }
    
    $results = @()
    
    ### Check if groups without overrides do exist in subscriptions (ignore these)
    
    foreach ($item in $preresults) {
        if ($subgroups -notcontains $item.ID) {
            ## $results += "$($item.ID)" +" : "+ "$($item.DN)"
            $results += "$($item.DN)"
        }
    }
    
    $results | Sort-Object




    Tuesday, May 31, 2016 11:50 AM