Sample code in SMO 10 that would enumerate SQL Server 2008 and 2005 Registered
Servers.

Steps
===================
The following sample code works fine and enumerates the Registered Servers (SQL
Server 2K5 and 2K8).
We would need to add the dll Microsoft.SqlServer.Management.RegisteredServers.dll
(Located in
C:\WINDOWS\assembly\GAC_MSIL\Microsoft.SqlServer.Management.RegisteredServers\10.0.0
.0__89845dcd8080cc91).
To view Microsoft.SqlServer.Management.RegisteredServers.dll you would need to
unregister shfusion.dll (Located in
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727).

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SqlServer.Management.RegisteredServers;



namespace ConsoleApplication1
{
class Program

{
static List<string> smoServers = new List<string>();
static List<Microsoft.SqlServer.Management.RegisteredServers.ServerGroup> smoGroups
= new List<Microsoft.SqlServer.Management.RegisteredServers.ServerGroup>();
static ServerGroup AllServersGroup = new ServerGroup();
static ServerGroup newGroup = new ServerGroup();
static ServerGroup childServerGroup = new ServerGroup();


static void Main(string[] args)
{


ImportSMOGroups();

}


static public void ImportSMOGroups()
{

// Load SMO Groups
foreach (Microsoft.SqlServer.Management.RegisteredServers.ServerGroup group
in RegisteredServersStore.LocalFileStore.ServerGroups)

{
if (group.ServerType ==
Microsoft.SqlServer.Management.Common.ServerType.DatabaseEngine
&& (group.ServerGroups.Count > 0
|| group.RegisteredServers.Count > 0))
{


ProcessSMOGroup(group, AllServersGroup);
smoGroups.Add(group);
}
}
}

static public void
ProcessSMOGroup(Microsoft.SqlServer.Management.RegisteredServers.ServerGroup group,
ServerGroup parent)
{

foreach (Microsoft.SqlServer.Management.RegisteredServers.RegisteredServer server
in group.RegisteredServers)
{
smoServers.Add(server.Name);
Console.WriteLine(server.Name.ToString());
}

Console.ReadLine();
// recurse through the subgroups

foreach (Microsoft.SqlServer.Management.RegisteredServers.ServerGroup subGroup
in group.ServerGroups)
{
ProcessSMOGroup(subGroup, newGroup);
smoGroups.Add(childServerGroup);
}
}
}
}