Pergunta

I have installed sharepoint 2010 farm in my organization. where machine 1 has Sql server r2, Machine 2 has Sharepoint server, Machine 3,4,5,6 has Front tier only.

I am writing the program in which i am trying to get the name of only sharepoint servers, not sql server. so i tried this line :

SPServerCollection collection = new SPServerCollection(SPFarm.Local);
                collection = SPFarm.Local.Servers;

But It should give me all servers in the farm, except Sql server instance. how to identify the server type like ..this is sp front tier,...this is sp central administration server.. in c#. How to do this ?

Also how to get web applications in each server. ?

Foi útil?

Solução

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();
    }
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top