views:

216

answers:

1

I have a sharepoint server farm like the following.

Machine1: Test_DB  in this machine i have installed SQL Server as named instance.
          (Test_DB\sqlserver)

Machine2: Test_appsrv Application server complete installation

Machine3: Test_web   in this installed sharepoint as webfront end.

In my central admin I am seeing all the 3 servers .

But when I iterate through the SpServer.ServerCollection I am getting the role as invalid for database server.

how to get it as correct....

Here is the piece of code

    static void Main(string[] args)
    {
        SPFarm farm = new SPFarm();
        farm = SPFarm.Local;
        SPServerCollection myServerCollection=farm.Servers;
        foreach (SPServer myServer in  myServerCollection)
        {
            Console.WriteLine(myServer.Name + " " + myServer.Role);
        }
        Console.Read();
    }

the out put i am getting is

Test_DB Invalid Test_appsrv application Test_web web front end

A: 

Look I have updated the Answer already to get the Instance of the DB Server. Please refer to your question.

Kusek