How To : VB Script to Remove the Machine Names from COM+ catalog.

We had a lot of remote servers configured in Component Services. Some of the servers later got decommissioned. Now when we try to click on the machine name nodes in Component Services it hangs and does not respond. We ran the VB script below to remove the machine name nodes from COM+ catalog.You need to be the local administrator on the machine to be able to run the script below:


' Script to delete Machine names from COM+ catalog
' ===========================================================

Dim catalog 'As COMAdmin.COMAdminCatalog
Dim Machines 'As COMAdminCatalogCollection

Set Catalog = CreateObject("COMAdmin.COMAdminCatalog")

'Collect input from user
Dim sMachine
sMachine = Inputbox("Enter Machine name to be deleted (case sensitive):","Delete Machine name", "My Computer")  
 If sMachine="" Then
    MsgBox"Invalid input, restart the program"
 End If
If sMachine="My Computer" Then
   msgbox ("You cannot delete My Computer")
End If

'Get the Machines collection in COM+ catalog
 Set Machines = Catalog.GetCollection("ComputerList")

'Get the count of the number of objects
 MsgBox("No. of Machine names found : " & Machines.Count)

'Get the correct machine name
 counter = 0
 Dim MachineObj 'As COMAdminCatalogObject
 For Each MachineObj in Machines
    If MachineObj.Name=sMachine Then
             Exit For            
    End If
    counter = counter +1

'Delete the machine name
If counter < machines.count Then
Dim answer
    answer = Msgbox("Are you sure you want to delete: " & sMachine, vbYesNo, "Confirm Deletion?")
    If answer=vbYes Then
    End If
   Msgbox "'" & sMachine & "' not found in the COM+ catalog.", vbOkOnly,"Machine Not Found"
End If