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 later # # Author: Kevin Holman # v1.1 #================================================================================= param([string]$ManagementServerName,[string]$ConnectorName) # Constants section - hard code settings here is wanted #================================================================================= # $ManagementServerName = "localhost" # $ConnectorName = "Test Conn*" #This can be a full name or a partial name match using * as a wildcard - so take great care here that you only pull back the connectors you wish to delete. #================================================================================= # BEGIN Function section #================================================================================= # Begin Delete-Subscription function #=========================================== # Delete a connector Subscription function Delete-Subscription($ConnectorsToDeleteArr,$SubscriptionsArr) { FOREACH($Connector in $ConnectorsToDeleteArr) { FOREACH($Subscription in $SubscriptionsArr) { IF($Subscription.MonitoringConnectorId -eq $Connector.id) { Write-Host "Deleting subscription: (" $Subscription.DisplayName ") from Connector: (" $Connector.Name ")." $admin.DeleteConnectorSubscription($Subscription) } } } } #=========================================== # End Delete-Subscription function # Begin Remove-Connector function #=========================================== function Remove-Connector($ConnectorsToDeleteArr) { FOREACH($Connector in $ConnectorsToDeleteArr) { IF ($Connector.Initialized) { Write-Host "Found connector: (" $Connector.Name ") is initialized, disconnecting all alerts subscribed to the connector" FOREACH ($Alert in $Connector.GetMonitoringAlerts()) { $alert.ConnectorId = $null; $alert.Update("Delete Connector"); } Write-Host "Setting connector: (" $Connector.Name ") to UnInitialized state" $Connector.Uninitialize() } Write-Host "Deleting connector: (" $Connector.Name ")." $DeleteConnector = $admin.Cleanup($Connector) } } #=========================================== # End Remove-Connector function #================================================================================= # END Function section # Begin MAIN script section #================================================================================= IF(!($ManagementServerName)) { #Assume localhost and running script locally on the management server $ManagementServerName = "localhost" } IF(!($ConnectorName)) { #We MUST have a ConnectorName to continue. Exit if we do not Write-Host "ConnectorName MUST be supplied. Terminating" } ELSE { #Connect to SCOM Management Group #Import the OperationsManager module and connect to the management group $SCOMPowerShellKey = "HKLM:\SOFTWARE\Microsoft\System Center Operations Manager\12\Setup\Powershell\V2" $SCOMModulePath = Join-Path (Get-ItemProperty $SCOMPowerShellKey).InstallDirectory "OperationsManager" Import-module $SCOMModulePath New-DefaultManagementGroupConnection -managementServerName $ManagementServerName #Connect to SDK and get connector framework and connectors $mg = Get-SCOMManagementGroup -ComputerName $ManagementServerName $admin = $mg.GetConnectorFrameworkAdministration() $ConnectorNamesToDelete = @() $ConnectorsToDelete = $admin.GetMonitoringConnectors() | where {$_.Name -like "$ConnectorName"} IF (!($ConnectorsToDelete)) { Write-Host "`nNo connectors were found searching for: ($ConnectorName). `nTerminating." PAUSE EXIT } #Get all the subscriptions $Subscriptions = $admin.GetConnectorSubscriptions() #Build array of connector names to verify before deleting FOREACH ($ConnectorToDelete in $ConnectorsToDelete) { [array]$ConnectorNamesToDelete += "`n" + $ConnectorToDelete.Name } Write-Host "`nAbout to delete the following connectors: `n" $ConnectorNamesToDelete Write-Host "`nPress Y to continue, or any other key to stop" $response = Read-Host IF ($response -ne "Y") { Write-Host "Terminating." PAUSE EXIT } IF (!($Subscriptions)) { Write-Host "There are no subscriptions configured on ANY product connectors. `nSkipping the deletion of Product Connector Subscriptions." } ELSE { Write-Host "`nStarting Delete-Subscription function...`n" Delete-Subscription $ConnectorsToDelete $Subscriptions } Write-Host "`nStarting Remove-Connector function...`n" Remove-Connector $ConnectorsToDelete Write-Host "`nCompleted script`n" } #END