Attribute VB_Name = "Module1" ' *************************************************************************** ' Copyright (C) 1991-2003 SQLDev.Net ' ' $BeginHeader$ ' ' @file@: RegisteredServers.bas ' @author@: Gert E.R. Drapers (GertD@SQLDev.Net) ' @description@: Example: List all Registered Servers using SQL-DMO ' @remarks@: ' @created@: 2003-03-03 ' @lastsaved@: 2003-03-03 ' ' update history: ' @version@ @initials@ @updatedate@ @release@ @description@ ' 00000 GED 2003-03-03 v1.0.0.0 created ' ' @EndHeader@ ' *************************************************************************** Option Explicit Public Sub main() On Error GoTo errHandler Dim oApplication As SQLDMO.Application Set oApplication = New SQLDMO.Application Dim oServerGroup As SQLDMO.ServerGroup Dim oRegisteredServer As SQLDMO.RegisteredServer oApplication.ServerGroups.Refresh ListServerGroups oApplication.ServerGroups Set oApplication = Nothing Exit Sub errHandler: Debug.Print Err.Number & " " & Err.Description Resume Next End Sub Private Sub ListServerGroups(ServerGroups As SQLDMO.ServerGroups) Dim oServerGroup As SQLDMO.ServerGroup For Each oServerGroup In ServerGroups If oServerGroup.ServerGroups.Count > 0 Then Call ListServerGroups(oServerGroup.ServerGroups) End If Call ListRegisteredServers(oServerGroup) Next End Sub Private Sub ListRegisteredServers(ServerGroup As SQLDMO.ServerGroup) Dim oRegisteredServer As SQLDMO.RegisteredServer For Each oRegisteredServer In ServerGroup.RegisteredServers Debug.Print ServerGroup.Name & " - " & oRegisteredServer.Name Next End Sub