Oude productconnectors verwijderen uit Operations Manager

In dit artikel wordt beschreven hoe u een oude productconnector verwijdert uit System Center Operations Manager met behulp van een PowerShell-script.

Oorspronkelijke productversie: System Center Operations Manager
Origineel KB-nummer: 2626670

Samenvatting

Het verwijderen van een oude productconnector uit System Center Operations Manager kan nodig zijn als de productconnector niet meer in de omgeving wordt gebruikt. Er is geen optie Verwijderen in de gebruikersinterface van de beheerconsole voor productconnectors, zodat het script kan worden gebruikt om de gewenste resultaten te bereiken.

PowerShell-script

Gebruik het volgende PowerShell-script om de productconnector te verwijderen:

Opmerking

Interne connectors mogen niet worden verwijderd. Zorg er ook voor dat u een back-up maakt van zowel de operationele database als de datawarehouse-database voordat u deze uitvoert. Sla ook de volgende scripts op als 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

Meer informatie

Gebruik: DeleteConnector.ps1 alinea1 alinea2

para1: Connectornaam

para2: Naam van beheerserver, optioneel, standaardwaarde: localhost

Als u probeert de interne Operations Manager-connector uit de database te verwijderen, wordt de volgende fout gegenereerd:

Uitzonderingsinhoud:

Uitzondering bij het aanroepen van 'Setup' met '1'-argument(en): 'Detectiegegevens gegenereerd door ongeldige connector:7431E155-3D9E-4724-895E-C03BA951A352'.