SPServer class

Represents a physical computer in the server farm.

Inheritance hierarchy

System.Object
  Microsoft.SharePoint.Administration.SPAutoSerializingObject
    Microsoft.SharePoint.Administration.SPPersistedObject
      Microsoft.SharePoint.Administration.SPPersistedUpgradableObject
        Microsoft.SharePoint.Administration.SPServer

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

Syntax

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

Remarks

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.

Examples

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()
SPServerCollection servers = SPFarm.Local.Servers;

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

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

Reference

SPServer members

Microsoft.SharePoint.Administration namespace