none
Uninstallation of agents - not reflecting in SCOM Windows computers RRS feed

  • Question

  • Hi Team,

    We are migrating the managed nodes from On-prem to Azure(lift and shift) only. Once they migrate the server, IP gets changed. 

    Old entry still exist in scom console windows computers. After going through the forums, I thought it will be removed after 3 or 4 days, now its been one week but those old entries are not being removed. I'm unable to re-install new agents, as it is not allowing me to add. It says, server is already being managed by SCOM. Please advise. 

    Friday, August 16, 2019 3:07 PM

All replies

  • Hi,

    what happens when you delete those old agents and then run

    Remove-SCOMDisabledClassInstance

    Afterwrads you should be able to add those agents again. 

    This one can help you also get rid of them (written by Kevon Holman):

    Deleting and Purging data from the SCOM Database

    Just conisder the following from the post:

    "First, I have to begin with a disclaimer – Microsoft does not support customers manually editing the database, unless under the guidance of a Microsoft support engineer with a support case."

    This solution is also very promissing, although I haven't tested it..(it should work also for SCOM 2016 and 2019 as the cmdlets are the same):

    How to Delete SCOM 2012 R2 Managed Computers using PowerShell Usage

    Regards,


    (Please take a moment to "Vote as Helpful" and/or "Mark as Answer" where applicable. This helps the community, keeps the forums tidy, and recognizes useful contributions. Thanks!) Blog: https://blog.pohn.ch/ Twitter: @StoyanChalakov


    Friday, August 16, 2019 3:24 PM
    Moderator
  • Your issue is a bit unclear for me. What makes you think moving a VM to Azure (or anywhere) and/or changing its ip should make it disappear from Windows Computers in SCOM?

    Also why would you like to reinstall the agent? If the agent was running properly before the lift&shift, I see no reason why it wouldn't work anymore afterwards...

    Last but not least, the title of the post says "uninstall" but nothing in the post itself describes any uninstallation. So... ?
    • Edited by CyrAz Friday, August 16, 2019 7:17 PM
    Friday, August 16, 2019 7:16 PM
  • Azure team does the complete migration itseems(not just life and shift), just verified with them. 

    moreover, after migration from on prem to azure, we are unable to edit agent manged server properties to update the new management server hence we do complete uninstallation and re-installation. While we do the uninstallation(after migration), servers are not being removed from windows computers(scom console). I waited for more than a week but it is not being removed due to this im unable to re-install agents. Please guide me further. 

    Monday, August 19, 2019 11:09 AM
  • Hi,

    did you try with PowerShell to remove the agent (the link I've posted)?

    Regards,


    (Please take a moment to "Vote as Helpful" and/or "Mark as Answer" where applicable. This helps the community, keeps the forums tidy, and recognizes useful contributions. Thanks!) Blog: https://blog.pohn.ch/ Twitter: @StoyanChalakov

    Monday, August 19, 2019 11:25 AM
    Moderator
  • Hi Stoyan,

    I'm bit scary to touch the DB now. I read through the link which you posted(Kevin's link). I need to apply the fix for 400 servers :( 

    Powershell script: I have also taken a look on the powershell script link. I shall try that in test and confirm you. 

    I'm not sure where to use below command. Please guide me . 

    Remove-SCOMDisabledClassInstance
    Tuesday, August 20, 2019 2:03 PM
  • https://www.scom2k7.com/downloads/DeleteSCOMAgents.ps1.txt

    Using this script, will it remove the servers from windows computers? Please note that agents are already been removed and entry alone exist in the windows computers(scom console)

    Tuesday, August 20, 2019 2:20 PM
  • Hi,

    I already posted the reference to this particular script, did you try it out? And yes, it should delete all the agents you give as an input to the script...

    Regards,


    (Please take a moment to "Vote as Helpful" and/or "Mark as Answer" where applicable. This helps the community, keeps the forums tidy, and recognizes useful contributions. Thanks!) Blog: https://blog.pohn.ch/ Twitter: @StoyanChalakov

    Tuesday, August 20, 2019 2:50 PM
    Moderator
  • Yes, I tried in test and it works fine from the console but inside the server agents are present. I tried in production, command itself is not executed and I get error. 

    Test:

    PS C:\> cd C:\Users\SCOMRAA\Desktop
    PS C:\Users\SCOMRAA\Desktop> .\DeleteSCOMAgents.ps1 -MSServer "cgs.hq.hrgy.com" -AgentComputerName "cgts.hq.huskyenergy.com"

    GAC    Version        Location
    ---    -------        --------
    True   v4.0.30319     C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.EnterpriseManagement.Core\v4.0_7.0.5000.0...
    True   v4.0.30319     C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.EnterpriseManagement.OperationsManager\v4...
    Connecting to management group
    Getting agent managed computers
    Checking for cgs.hq.huskyenergy.com
    Matched cgts.hq.huskyenergy.com
    Deleting agents
    Agents deleted

    Production:
    PS C:\Users\SCOMRAA\Desktop> .\DeleteSCOMAgents.ps1 -MSServer "wsi.hq.com" -AgentComputerName "CGW.hq.com"

    GAC    Version        Location
    ---    -------        --------
    True   v4.0.30319     C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.E...
    True   v4.0.30319     C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.E...
    Connecting to management group
    New-Object : Exception calling ".ctor" with "1" argument(s): "The Data Access
    service is either not running or not yet initialized. Check the event log for
    more information."
    At C:\Users\SCOMRAA\Desktop\DeleteSCOMAgents.ps1:24 char:22
    + $ConnectionSetting = New-Object
    Microsoft.EnterpriseManagement.ManagementGroup($ ...
    +
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvoca
       tionException
        + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.Power
       Shell.Commands.NewObjectCommand

    You cannot call a method on a null-valued expression.
    At C:\Users\SCOMRAA\Desktop\DeleteSCOMAgents.ps1:25 char:1
    + $admin = $ConnectionSetting.GetAdministration()
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull

    Getting agent managed computers
    You cannot call a method on a null-valued expression.
    At C:\Users\SCOMRAA\Desktop\DeleteSCOMAgents.ps1:29 char:1
    + $agentManagedComputers = $admin.GetAllAgentManagedComputers()
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull

    Checking for CGW.hq.com



    • Edited by Zikki_Asks Tuesday, August 20, 2019 3:48 PM
    Tuesday, August 20, 2019 3:43 PM
  • Please note that the managed  node is not present in Agent managed but only in windows computers. I logged in to the managed server to get the management server name. 
    Tuesday, August 20, 2019 3:46 PM
  • Hi,

    it seems it cannot connect to your Managament Group properly. 

    Please check if Port 5724 (TCP) is open to you management server.
    Make sure no firewall blocks the connection, disable the Windows Firewall for testing purposes.
    Please try connecting to another management server.

    The error:

    "The Data Access service is either not running or not yet initialized. Check the event log for more information."

    means that you cannot connect to the Management Group.

    Regards,


    (Please take a moment to "Vote as Helpful" and/or "Mark as Answer" where applicable. This helps the community, keeps the forums tidy, and recognizes useful contributions. Thanks!) Blog: https://blog.pohn.ch/ Twitter: @StoyanChalakov

    Tuesday, August 20, 2019 3:49 PM
    Moderator
  • I have edited my previous post, please read again. Also, note that I used my gateway server in my last command that I was the issue. I edited the MS name and ran the command again, it got executed but no changes. Server was not removed from windows computers. 

    PS C:\Users\SCOMRAA\Desktop> .\DeleteSCOMAgents.ps1 -MSServer "cgas.hq.hy.com" -AgentComputerName "CGW.hq.hgy.com"

    GAC    Version        Location
    ---    -------        --------
    True   v4.0.30319     C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.EnterpriseManagement.Core\v4.0_7.0.5000.0...
    True   v4.0.30319     C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.EnterpriseManagement.OperationsManager\v4...
    Connecting to management group
    Getting agent managed computers
    Checking for CGW.hq.hrgy.com

    Tuesday, August 20, 2019 3:59 PM
  • Hi,

    this won't work for a Gateway, only for normal SCOM Agents. I think you will need to remove the Gateway separately and use the script for all other SCOM agents.

    Regards,


    (Please take a moment to "Vote as Helpful" and/or "Mark as Answer" where applicable. This helps the community, keeps the forums tidy, and recognizes useful contributions. Thanks!) Blog: https://blog.pohn.ch/ Twitter: @StoyanChalakov

    Tuesday, August 20, 2019 4:18 PM
    Moderator
  • Not sure why it dint work for normal SCOM agents as well. It got removed from the console but not from the managed node. 

    Test:

    PS C:\> cd C:\Users\SCOMRAA\Desktop
    PS C:\Users\SCOMRAA\Desktop> .\DeleteSCOMAgents.ps1 -MSServer "cgs.hq.hrgy.com" -AgentComputerName "cgts.hq.huskyenergy.com"

    GAC    Version        Location
    ---    -------        --------
    True   v4.0.30319     C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.EnterpriseManagement.Core\v4.0_7.0.5000.0...
    True   v4.0.30319     C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.EnterpriseManagement.OperationsManager\v4...
    Connecting to management group
    Getting agent managed computers
    Checking for cgs.hq.huskyenergy.com
    Matched cgts.hq.huskyenergy.com
    Deleting agents
    Agents deleted

    Tuesday, August 20, 2019 4:28 PM
  • Will this command help my issue.

    Remove-SCOMDisabledClassInstance

    Tuesday, August 20, 2019 4:30 PM
  • Hi

    From what I'm understanding by reading through the replies, after you click "Uninstall" from the console, the agent disappears from the "agent Managed" view but remains in the "Windows Computer" view? And also the actual agent is NOT uninstalled from the target machine?

    If yes, I think running the "Remove-SCOMDisabledClassInstance" should fix your first issue. You run this on the MS with an admin PS window. Let us know how that goes. You can also refer this article to remove the "ghost agents" from the console.

    https://blogopsmgr.wordpress.com/2016/03/31/remove-orphaned-entries-scom/

    Second part however is stranger. After clicking the uninstall button, check the events on the MS as well as the agent, what do you see there? Are you sure there is no other mechanism in place that is re-installing the agents if deleted?

    Cheers


    Sam (Please take a moment to "Vote as Helpful" and/or "Mark as Answer" wherever applicable. Thanks!) Blog:AnalyticOps Insights Twitter:Sameer Mhaisekar

    Thursday, August 22, 2019 7:05 AM
  • As far as I know, Remove-SCOMDisabledClassInstance is specifically made to undiscover instances of classes for which the discovery rule has been overriden>disabled.

     Nothing more, nothing less.

    Based on that, I don't believe it can help in this situation...

    • Edited by CyrAz Thursday, August 22, 2019 7:34 AM
    Thursday, August 22, 2019 7:33 AM
  • As far as I know, Remove-SCOMDisabledClassInstance is specifically made to undiscover instances of classes for which the discovery rule has been overriden>disabled.

     Nothing more, nothing less.

    Based on that, I don't believe it can help in this situation...

    CyrAz is absolutely right about this. Sometimes, when you remove a SCOM agent (tested this over SDK) there are some leftovers, orphaned computer objects under “Monitoring\Windows Computer”. After running the cmdlet, those get deleted. I had this phenomenon back then as I was automaitng SCOM agent removal (wrote and article also at that time). 

    But now, knowing more about the challenge in the particular case, I don't think running the cmdlet will change something. Nevertheless, runnin this is not harmful, so a just go ahead and give it a try. 

    Regards,


    (Please take a moment to "Vote as Helpful" and/or "Mark as Answer" where applicable. This helps the community, keeps the forums tidy, and recognizes useful contributions. Thanks!) Blog: https://blog.pohn.ch/ Twitter: @StoyanChalakov

    Thursday, August 22, 2019 7:42 AM
    Moderator
  • To be perfectly honest, it could be harmful under certain very specifc circumstances : http://thoughtsonopsmgr.blogspot.com/2016/01/om12x-ps-school-of-hard-knocks-beware.html

    Thursday, August 22, 2019 8:34 AM
  • To be perfectly honest, it could be harmful under certain very specifc circumstances : http://thoughtsonopsmgr.blogspot.com/2016/01/om12x-ps-school-of-hard-knocks-beware.html

    Well, after reading Marnix's article I changed my mind - it could be harmful. But you have also a point with "under very specific circumstances". 


    (Please take a moment to "Vote as Helpful" and/or "Mark as Answer" where applicable. This helps the community, keeps the forums tidy, and recognizes useful contributions. Thanks!) Blog: https://blog.pohn.ch/ Twitter: @StoyanChalakov

    Thursday, August 22, 2019 9:03 AM
    Moderator
  • Thank God!

    You saved me from executing this command. 

    Thursday, August 22, 2019 2:06 PM
  • Touching the DB has to go through lot of process in my environment hence checking out other feasible solution that could be done from front end. I shall have these steps in handy so that I use them at one point. I have nearly 22 servers, which is reflecting in the windows computers but it has been removed from agent managed(agents removed from the managed node though). As per my findings, these happen for the SCOM agents manually installed servers. 

    Thursday, August 22, 2019 2:11 PM
  • To be perfectly honest, it could be harmful under certain very specifc circumstances : http://thoughtsonopsmgr.blogspot.com/2016/01/om12x-ps-school-of-hard-knocks-beware.html

    Hmm..interesting indeed. However, the problem there was caused by some confusion that happened to be related to a very important class specifically in this case. So I think the Remove-SCOMDisabledClassInstance in itself is not at the root of that problem. So running that cmd in itself will not cause any harm. You just need to be careful what discoveries you've disabled! Very educative blog though!

    Cheers


    Sam (Please take a moment to "Vote as Helpful" and/or "Mark as Answer" wherever applicable. Thanks!) Blog:AnalyticOps Insights Twitter:Sameer Mhaisekar

    Sunday, August 25, 2019 6:50 PM