Share via

SPServer Class

Represents a physical computer in the server farm.

Inheritance Hierarchy


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 NotInheritable Class SPServer _
    Inherits SPPersistedUpgradableObject
Dim instance As SPServer
[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.

Dim servers As SPServerCollection = SPFarm.Local.Servers

Dim myServer As SPServer = servers("myExistingServer")
myServer.Name = "NewServerName"
myServer.Role = SPServerRole.Application
SPServerCollection servers = SPFarm.Local.Servers;

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

Thread Safety

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

See Also


SPServer Members

Microsoft.SharePoint.Administration Namespace