How to remove old product connectors from System Center Operations Manager 2007

Article ID: 2626670
Expand all | Collapse all

SYMPTOMS

Removing an old product connector from System Center Operations Manager 2007 (OpsMgr 2007) may be necessary if the product connector is no longer used in the environment. There is no Delete option in admin console UI for product connectors so the script below can be used to achieve the desired results.

RESOLUTION

Use the following PowerShell script to remove the product connector:

Note Internal Connectors should not be removed, also be sure to backup both the Operational DB and the Data Warehouse before running this. Also save the below as DeleteConnector.ps1

param(
    [String] $connectorName,
    [String] $mgName="localhost"
)

add-pssnapin Microsoft.EnterpriseManagement.OperationsManager.Client
$installDirPS = (get-itemproperty -path 'hklm:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup' -name InstallDirectory).InstallDirectory
set-location $installDirPS
Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Startup.ps1
 
$mg = new-object Microsoft.EnterpriseManagement.ManagementGroup $mgName
$admin = $mg.GetConnectorFrameworkAdministration()

##########################################################################################
# Configures a connector with the specified name.
##########################################################################################
function New-Connector([String] $name)
{
    $connectorForTest = $null;
    foreach($connector in $admin.GetMonitoringConnectors())
    {
     if($connector.Name -eq ${name})
     {
      $connectorForTest = Get-Connector -id $connector.id
     }
    }
   
    if ($connectorForTest -eq $null)
    {
        $testConnector = New-Object Microsoft.EnterpriseManagement.ConnectorFramework.ConnectorInfo
        $testConnector.Name = $name
        $testConnector.Description = "${name} Description"
        $testConnector.DiscoveryDataIsManaged = $false
        $connectorForTest = $admin.Setup($testConnector)
        $connectorForTest.Initialize();
    }
    return $connectorForTest
}


##########################################################################################
# Removes a connector with the specified name.
##########################################################################################
function Remove-Connector([String] $name)
{
    $testConnector = $null
    foreach($connector in $admin.GetMonitoringConnectors())
    {
     if($connector.Name -eq ${name})
     {
      $testConnector = Get-Connector -id $connector.id
     }
    }
    if ($testConnector -ne $null)
    {
    if($testConnector.Initialized)
    {
    foreach($alert in $testConnector.GetMonitoringAlerts())
    {
     $alert.ConnectorId = $null;
     $alert.Update("Delete Connector");
    }
    $testConnector.Uninitialize()
    }
    $connectorIdForTest = $admin.Cleanup($testConnector)
    }
}

##########################################################################################
# Delete a connector's Subscription
##########################################################################################
function Delete-Subscription([String] $name)
{
 foreach($testconnector in $admin.GetMonitoringConnectors())
 {
   if($testconnector.Name -eq $name)
   {
     $connector = Get-Connector -id $testconnector.id
   }
 }
 $subs = $admin.GetConnectorSubscriptions()
 foreach($sub in $subs)
 {
  if($sub.MonitoringConnectorId -eq $connector.id)
  {
   $admin.DeleteConnectorSubscription($admin.GetConnectorSubscription($sub.Id))
  }
 }
}

#New-Connector $connectorName
write-host "Delete-Subscription"
Delete-Subscription $connectorName
write-host "Remove-Connector"
Remove-Connector $connectorName

MORE INFORMATION

Usage: DeleteConnector.ps1 para1 para2

para1: Connector Name

para2: MS name, Optional, default value: localhost


Note If you attempt to delete the Operations Manager Internal Connector from the database it will generate the following error:

Exception content:

Exception calling "Setup" with "1" argument(s): "Discovery data generated by invalid connector:7431E155-3D9E-4724-895E-C03BA951A352."
Note This is a "FAST PUBLISH" article created directly from within the Microsoft support organization. The information contained herein is provided as-is in response to emerging issues. As a result of the speed in making it available, the materials may include typographical errors and may be revised at any time without notice. See Terms of Use for other considerations.

Properties

Article ID: 2626670 - Last Review: October 13, 2011 - Revision: 3.0
Keywords: 
KB2626670

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com