Command Shell Examples
Useful SQL Queries
Remove-DisabledMonitoringObject - Jonathan Almquist on Operations Manager - Site Home - TechNet Blogs

Remove-DisabledMonitoringObject

Remove-DisabledMonitoringObject

  • Comments 25
  • Likes

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.

actions

 

As you can see, I have 8 agents enabled for Client Perspective.  In this example, I'd like to remove 3 of these objects.

01 - Discovered Inventory 1

 

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.

02 - Object Discovery for AD Client Perspective

 

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.

03 - Create group targeting Windows Computer class

 

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).

04 - Override for group

 

Now, open Operations Manager Command Shell and run

Remove-DisabledMonitoringObject

 

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 :)

05 - Discovered Inventory 1

 

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...

I do not moderate this blog anymore. If you have a question regarding this post, send me a message.

Comments
  • I wonder to know that whay some time  the in the Discovered Inventory the state of the comuter is gry but insted of green?

  • Hi Ramila,

    If any objects are in a grey "state", this means that monitoring workflows targeting that object are not running due to some issues with the Health Service.  It usually comes down to the Health Service not running, or the computer is unresponsive or unreachable.

    -Jonathan

  • Thanks. Jonathan. your answer was so helpfull.

    I wonder to know that how can I fix the problem?

    what is  the next step If I want to solve this problem

    ?

  • Hi Ramila,

    There are plenty of discussions in the forums and blogs around how to troubleshoot grey agents.  The first step is to restart the Health Service on the Agent and look in the Operations Manager event log for any warning and error events.  Anything beyond that would need to be taken up in a forum with your peers.  Sorry, I can't help much here in the comments of this post.

    Try here:

    http://social.technet.microsoft.com/Forums/en-US/category/systemcenteroperationsmanager

    -Jonathan

  • Wonderful info!!! 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 but what happens when we upgrade the MP from one version (Enable = FALSE) to another version (ENABLE = TRUE) still the Remove-DisabledMonitoringObject works i suspect because in our case it's not removing the lingering instances of previous version.

  • Shindhe,

    That's right.  Remove-DisabledMonitoringObject removes inventory that was discovered where the discovery enabled property has been set to False (aka, disabled).

    -Jonathan

  • We received an important reminder today from the product group about manually editing the database, and

  • great help!!  i was suffering after shutting down a cluster, several gray resources groups.

    Anyway i think this issue is solved with CU2, can you confirm this please?

    Thanks.

  • I'm trying to use this cmdlet and it seems that is not working properly. First of all, it seems that arguments -WhatIf and -Confirm are not working at all. Apart from this issue, the cmdlet is not deleting objects in some circustances. I'm trying to remove some Solaris 9 Logical Disks discovered by the Solaris 9 Operative System MP without success. Has anyone else had problems removing discovered objects?

  • @great - yes, some of these cluster deletion issues were resolved in the CU's.

    @Andre's - I haven't heard any issues with this cmdlet not working as described.  Make sure you have the discoveries disable for the instances you want to delete.  I don't have experience removing x-plat instances, though, so maybe you would find the Technet forums more helpful in that area.

    social.technet.microsoft.com/.../systemcenteroperationsmanager

  • Any thoughts on those computers which are discovered under AD Topolgy discovery but still does not removed after enabling discover agent only option as override. So tried by disabling the discovery rule for AD topology and ran this cmdlet many times. Also mofied the interval tovery  frequent in discovery rule before running the cmdlet.

  • @dipeshr - make sure your management server action account is a member of the SCOM Administrators user role for agent-only option to work on this discovery, because there is a Powershell script that runs in this case and call get-agent.  If the MSAA doesn't have SCOM Admin privileges, the discovery cannot execute the cmdlet.

  • Thanks Jonathan. Yes, i have verified that management server action account is a member of SCOM administrator. I do not see any errors or information of powershell script also. I ran get-agent command to verify that agent is not in list and even verified the directory for powershell as well.

  • I used to run the "Remove-DisabledMonitoringObject" cmdlet without any issues, but of late it's giving this timed out error! Any ideas?

    >Remove-DisabledMonitoringObject

    Remove-DisabledMonitoringObject : The requested operation timed out.

    At line:1 char:31

    + Remove-DisabledMonitoringObject <<<<

  • You might need to run it multiple times to remove all inventory, especially in loaded environments when removing a high volume of objects.  This is because there is a timeout on the procedure that this cmdlet executes.