| Below is the code to get name of all the server available in the farm with there address and roles.
SPFarm farm = SPFarm.Local;
Console.WriteLine("Below are the list of servers in Farm");
foreach (SPServer server in farm.Servers)
{
Console.WriteLine("ServerName", server.Name);
Console.WriteLine("ServerAddress", server.Address);
Console.WriteLine("ServerRole", server.Role);
}
| | |