Compartilhar via


Como remover conectores de produtos antigos do Operations Manager

Este artigo descreve como remover um conector de produto antigo do System Center Operations Manager usando um script do PowerShell.

Versão original do produto: System Center Operations Manager
Número original do KB: 2626670

Resumo

A remoção de um conector de produto antigo do System Center Operations Manager pode ser necessária se o conector de produto não for mais usado no ambiente. Não há opção Excluir na interface do usuário do console de administração para conectores de produto, portanto, o script pode ser usado para obter os resultados desejados.

Script do PowerShell

Use o seguinte script do PowerShell para remover o conector do produto:

Observação

Os conectores internos não devem ser removidos, certifique-se também de fazer backup do banco de dados operacional e do banco de dados do data warehouse antes de executá-lo. Salve também os scripts a seguir como 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

Mais informações

Uso: DeleteConnector.ps1 para1 para2

para1: Nome do conector

para2: Nome do servidor de gerenciamento, Opcional, valor padrão: localhost

Se você tentar excluir o conector interno do Operations Manager do banco de dados, ele gerará o seguinte erro:

Conteúdo de exceção:

Exceção chamando "Setup" com argumentos "1": "Dados de descoberta gerados por conector inválido:7431E155-3D9E-4724-895E-C03BA951A352."