다음을 통해 공유


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)
Available in Sandboxed Solutions: No

Syntax

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