Removing unwanted product connectors in SCOM 2012 R2 and SCOM 2016


 

image

 

There are certain management packs that will use product connectors to insert discovery data into SCOM, or to manage alerts.  Sometimes, you might find that the vendor did not provide a way to remove these product connectors, when you decide to stop using the MP or solution which created them.

Below is a PowerShell script that will allow you to remove them.  It supports inputting the product connector by name, or by a wildcard match using “*”.  The script will output all the matching connectors and allow you to choose to continue if you want them deleted.

***NEVER remove any product connector unless you are absolutely SURE of its origin and that it is one you want to delete.  It is a good idea to back up your databases before deleting connectors.

 

#=================================================== # # Delete a SCOM product connector in SCOM 2012 R2 and SCOM 2016 # # v1.0 # #=================================================== #=================================================== # Constants section - make changes here $connectorName = "foo.connector*" #This can be a full name or a partial name match with a wildcard (*) - so take great care here $servername="localhost" #=================================================== $mg = Get-SCOMManagementGroup -ComputerName $servername $admin = $mg.GetConnectorFrameworkAdministration() $connectors = $admin.GetMonitoringConnectors() $subs = $admin.GetConnectorSubscriptions() $ToBeDeletedNames = @() $ToBeDeletedList = $admin.GetMonitoringConnectors() | where {$_.Name -like "$connectorname"} FOREACH ($ToBeDeletedConn in $ToBeDeletedList) { [array]$ToBeDeletedNames += "`n" + $ToBeDeletedConn.Displayname } Write-Host "About to delete the following connectors: " $ToBeDeletedNames Write-Host "Press Y to continue, or any other key to stop" $response = Read-Host if ( $response -ne "Y" ) { Write-Host "Cancelling" exit } ########################################################################################## # Delete a connector’s Subscription ########################################################################################## function Delete-Subscription([String] $name) { foreach($testconnector in $connectors) { if($testconnector.Name -match $name) { $connector = Get-SCOMConnector -id $testconnector.id write-host "Found match on connector:" $connector.Displayname foreach($sub in $subs) { if($sub.MonitoringConnectorId -eq $connector.id) { write-host "Deleting subscription:" $sub.DisplayName "with ID" $sub.MonitoringConnectorId $admin.DeleteConnectorSubscription($admin.GetConnectorSubscription($sub.Id)) } } } } } ########################################################################################## # Removes a connector with the specified name. ########################################################################################## function Remove-Connector([String] $name) { $testConnector = $null foreach($connector in $connectors) { IF ($connector.Name -like $name) { $testConnector = Get-SCOMConnector -id $connector.id write-host "Found match on connector:" $connector.Displayname IF ($testConnector -ne $null) { IF ($testConnector.Initialized) { Write-Host "Found connector is initialized, disconnecting all alerts subscribe to the connector" FOREACH ($alert in $testConnector.GetMonitoringAlerts()) { $alert.ConnectorId = $null; $alert.Update("Delete Connector"); } Write-Host "Setting connector to UnInitialized" $testConnector.Uninitialize() } Write-Host "Deleting connector:" $testConnector.DisplayName "with ID" $testConnector.Id $connectorIdForTest = $admin.Cleanup($testConnector) } } } } write-host "Starting Delete-Subscription function" Delete-Subscription $connectorName write-host "Starting Remove-Connector function" Remove-Connector $connectorName

Comments (7)

  1. Shery Cherian says:

    Thanks Kevin,
    Script works perfectly , I have removed 350 Connectors created by NetApp in my prod environment
    Save my Day & Time….

    1. Kevin Holman says:

      Thanks!

      I actually wrote this for a customer – who had the same issue – hundreds of NetAPP connectors that they wanted to clean up – and deleting the MP’s from NetAPP won’t clean up the old unused connectors. That’s exactly why I included wildcard support – because most have a very similar name.

      1. Shery Cherian says:

        Hi Kevin,

        I have observed that Netapp connectors are rebuilding once we run the discovery, looks like Net App inbuilt the connectors in the discovery code.This is happening only on Clustered Data ONTAP not on 7-mode Data ONTAP MP.

        Do you have any updates on this issue?

        1. Kevin Holman says:

          If the SCOM connectors are coming back – that means you still have the NetAPP MP’s imported. You should NEVER delete connectors that are designed to work with management packs you still have installed. This process to delete connectors is ONLY for old, unwanted connectors where the solution using them has been removed.

          1. Shery Cherian says:

            Yes Kevin, but creating 400 plus connectors in a single MP always cause problems in Console.
            I am working with Net App community to find a fix or some kind of workaround.

            https://community.netapp.com/t5/Data-ONTAP-Discussions/OnCommand-Clustered-Data-ONTAP-4-1-1-7474-SCOM-Internal-Connectors/m-p/129179/highlight/false#M28072

  2. Tobias Hennighausen says:

    hello everyone,

    as a workaround – is it possible to deactivate the “Forward to” entry when the right click is used in the alert view? Am I guessing correct that this function slows down the console if so many connectors are existing?

  3. Murad says:

    Worked perfectly on SCOM 2016 with UR3 and I was able to remove 33 SCVMM product connectors left behind due to SCVMM server decommissioned without/before removing the SCVMM/SCOM integration. This was a big headache for me as there were hundreds of Application event log errors (i.e. Event ID: 25933; 25934) logged every hour/daily so thank you for writing this script.

Skip to main content