[OpsMgr] Bulk overrides deletion thru Powershell

Posted: September 14, 2011 in SCOM, SCOM 2007

Unfortunately, SCOM does not provide us possibility to delete number of overrides at once.
Here is PS script to help us.

$mp=get-managementpack | where {$_.Name -eq 'MP_name_goes_here'}
$mp | get-override | where {$_.Name -match 'name_goes_her' -and $_.Value -eq common_value_goes_here} | %{$_.Status=[Microsoft.EnterpriseManagement.Configuration.ManagementPackElementStatus]::PendingDelete}
$mp.AcceptChanges()

key points
1. identify MP which holds our overrides.
2. pull filtered overrides.
3. mark them for deletion (Status=’PendingDelete’)
4. commit changes

Advertisements
Comments
  1. Curtiss says:

    can you update this for 2012? the commands are different and i can’t get it to work even with the new commands.

  2. scompro says:

    Hi Curtiss. Nice catch. 🙂
    I will look into this shortly

  3. Sandor says:

    Hello,
    I used your example to create my own script. I am using it for SCOM 2012. What I realize that in 2012 this command works only for Discoveries.
    I created a script which reads monitors, rules, and discoveries from a file and check them. If any of them have an override which has a “false” value for the “Enabled” property the script should delete it and at the end of the script it will run the AcceptChanges() to finalize the changes.
    I run that script with monitors, rules, and discoveries. After that I realized that only the overrides of the discoveries was deleted, the others are still there.
    Do you have any idea what could be the different in case of monitors and rules?
    Thanks

  4. Timothy says:

    For 2012+, do this… (Note: you can also use DisplayName instead of Name if it’s easier)

    $mp=get-scommanagementpack -Name ‘MP_name_goes_here’
    $mp.GetOverrides() | where {$_.Name -match ‘name_goes_her’ -and $_.Value -eq common_value_goes_here} | %{$_.Status=[Microsoft.EnterpriseManagement.Configuration.ManagementPackElementStatus]::PendingDelete}
    $mp.AcceptChanges()

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