Before I dive into the mechanics of removing discovered inventory, I want to attempt a quick definition of this cmdlet and it’s intended use.
An object (MonitoringObject) is an instance of a class (MonitoringClass). So, if an object is removed (Remove-DisabledMonitoringObject) from discovered inventory, monitoring defined for (targeting) that class will not be delivered to that object. Because, as far as that MonitoringClass is concerned, that MonitoringObject does not exist.
A couple reasons why this cmdlet is useful.
1. It enables us to quickly remove discovered objects, in order to remove these instances from being included in workflows from a MP, instead of going through a mountain of rules and monitors and creating disable overrides.
2. It enables us to cleanup discovered objects. For example – we create a group of agents to include in AD Client Monitoring after the ADMP is imported. Down the road, it is decided that we don’t want some of those agents to participate in AD Client Monitoring. So we remove a few agents from the group, but the discovered objects remain…hence, the AD Client Monitoring workflow is still delivered to that agent. We need to run the cmdlet to finish the job. A little more about this at the end.
For this example, I will be removing AD Client Monitoring objects. This example assumes you have ADMP imported with some agents enabled for AD Client Monitoring. However, the steps are the same for any kind of inventory you wish to remove.
First, open up the console and take a look at the Monitoring pane > Discovered Inventory. In the Action pane, click Change target type. Select Active Directory Client Perspective.
As you can see, I have 8 agents enabled for Client Perspective. In this example, I’d like to remove 3 of these objects.
What I need to do here, is go into the Authoring pane > Object Discoveries. Scope to Active Directory Client Perspective. As you see, the discovery is targeting Windows Computer. This is what we need to target to remove the discovered objects.
Now, we could go ahead and disable override for specific agents. But, if you have more than a handful, you might consider creating a group. Either way, we’re going to need to target Windows Computer in order for this to work.
I’m creating a group, targeting Windows Computer, and adding my 3 explicit members.
After our group is created, let’s go back to Authoring > Object Discoveries. Override the discovery for a group. In the override, select the Enable parameter and change to False. Remember to save to your MP (not default MP).
Now, open Operations Manager Command Shell and run
There is no indication in the cmdlet that anything really happened. But, if you go back to the Monitoring pane > Discovered Inventory, you’ll notice that the inventory has disappeared. This is fairly instantaneous. If your inventory is still there, go to step one
A little tip on removing discovered objects for optional discovery rules. Let’s say…AD Client Monitoring! As we know, this discovery is not enabled by default. We create a group and apply an enable override to it, in order to get AD Client Monitoring to the agent. One might think that in order remove AD Client Monitoring from a couple agents down the road, we may just remove those couple of agents from the group and run the Remove-DisabledMonitoringObject cmdlet. Because the discovery is not enabled by default…right?
Unfortunately, that’s not the case. I’ll explain why.
Remove-DisabledMonitoringObject will only remove inventory that has already been discovered, for objects that have an override for Enable = FALSE explicitly for the discovery rule. In this case, an object has been discovered by enabling the discovery rule for it by setting override Enable = TRUE. If you were to remove the override for that object, it would go back to its default setting…which is “not configured”. In essence, it “tattoos” the setting. In order for Remove-DisabledMonitoringObject to work, the object needs to have an override Enable = FALSE to explicitly disable the discovery rule and for Remove-DisabledMonitoringObject to work.
So, you’ll still need to remove these objects from the original group you created to enable their discovery. From there, you can follow two paths.
1. We could create a group, populate it with only those objects we want to remove, disable override the discovery for that group, and run the cmdlet. Then, to keep things nice and tidy, we need to delete our group we just created to remove those agents. But that’s a lot of work!
2. Change the enable parameter for our original discovery override to false, run the cmdlet. Then change the enable back to true. This will, in effect, remove all disabled monitoring objects from discovered inventory then add them back…but this time, without the objects you intend to remove.
I hope I made sense out of removing optional discovery rule inventory…