SPServer class

Represents a physical computer in the server farm.

Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

'Declaration
<UpgradableAttribute> _
<GuidAttribute("E77AAF47-3CAC-4001-BC6B-5BCCB6486318")> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public NotInheritable Class SPServer _
	Inherits SPPersistedUpgradableObject
'Usage
Dim instance As SPServer

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
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: