Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

SPServer Class

Represents a physical computer in the server farm.

Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

[GuidAttribute("E77AAF47-3CAC-4001-BC6B-5BCCB6486318")]
[UpgradableAttribute]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public sealed class SPServer : SPPersistedUpgradableObject

Use either the Servers property of the SPFarm class, or the SPServerCollection constructor, to get the collection of servers that are used in the specified server farm. Use an indexer to return a single server from the collection. For example, if the collection is assigned to a variable named myServers, use myServers[index] in C#, or myServers(index) in Visual Basic, where index is either the GUID or the name that identifies the service.

The following example modifies the name and role of an existing server in the server farm.

SPServerCollection servers = SPFarm.Local.Servers;

SPServer myServer = servers["myExistingServer"];
myServer.Name = "NewServerName";
myServer.Role = SPServerRole.Application;
myServer.Update();

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2015 Microsoft