It is known since Operations Manager 2007 that discovered objects can only be removed by the rule that discovered them (when the objects do not longer exist) or by disabling the rule itself for the specific objects set. The second scenario is quite common when, for example, we want to avoid SQL Server to be monitored on a specific computer. It is also known that disabling the rule is not enough a special cleanup process must be started to actually remove the objects from the database.
In Operations manager 2007 this process could be started via the powershell cmdlet Remove-DisabledMonitoringObject. In System Center 2012 Operations Manager the cmdlet has been rewritten and renamed in Remove-SCOMDisabledClassInstance. This rewrite added a confirmation question such as the following:
**WARNING** This operation WILL result in class instances and relationships being permanently deleted. This operation is irreversible and will likely result in a significant amount of activity in the operational database. Are you sure you want to do
This is fine if you want to run the command one shot, but if you want to schedule it, you are out of luck. In fact, the cmdlet author didn’t follow powershell best practices implementing the Confirm common parameter to let the user bypass the confirmation question. A common scenario is when you want removal to be scheduled once a day off peak hours, so that every disabled discovery rule can lead to the removal of the corresponding object(s).
Fortunately, with a couple of lines of SDK we can implement the same action without the confirmation question. Therefore, if you want to schedule the removal of discovery-disabled objects you just need to schedule the following powershell script:
Hope it helps
This posting is provided “AS IS” with no warranties, and confers no rights.