Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AF SDK Reference

PIServer Class

  • Last UpdatedNov 18, 2025
  • 17 minute read
PIServer Class
The PIServer object represents a single PI Data Archive.

Inheritance Hierarchy

SystemObject
  OSIsoft.AFAFObject
    OSIsoft.AF.PIPIServer

Namespace:  OSIsoft.AF.PI
Assembly:  OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182

Syntax

[SerializableAttribute]
public sealed class PIServer : AFObject, 
	IAFTimeSource, IAFChangedEvent, ISerializable, IPIPersist, IComparable<PIServer>, 
	IEquatable<PIServer>
<SerializableAttribute>
Public NotInheritable Class PIServer
	Inherits AFObject
	Implements IAFTimeSource, IAFChangedEvent, ISerializable, IPIPersist, 
	IComparable(Of PIServer), IEquatable(Of PIServer)

Dim instance As PIServer
[SerializableAttribute]
public ref class PIServer sealed : public AFObject, 
	IAFTimeSource, IAFChangedEvent, ISerializable, IPIPersist, IComparable<PIServer^>, 
	IEquatable<PIServer^>
[<SealedAttribute>]
[<SerializableAttribute>]
type PIServer =  
    class
        inherit AFObject
        interface IAFTimeSource
        interface IAFChangedEvent
        interface ISerializable
        interface IPIPersist
        interface IComparable<PIServer>
        interface IEquatable<PIServer>
    end

The PIServer type exposes the following members.

Properties

  NameDescription
Public property
AliasNames
The list of alias names for the PIServer.
Public property
AuthenticationMode
Read-only property that returns the supported Authentication Modes of the .
Public property
Collective
This property returns information and status about the PIServer collective.
Public property
ConnectionInfo
This property returns information about the connection to the PIServer from the local computer.
Public property
CurrentUserIdentities
Gets the list of PIIdentity identities of the person who is currently logged on to the PIServer server.
Public property
CurrentUserIdentityString
Gets the security identity string of the person who is currently logged on to the PIServer server.
Public property
CurrentUserName
Gets the user name of the person who is currently logged on to the PIServer server.
Public property
DatabaseSecurities
This is the PIDatabaseSecurity collection of the PIServer.
Public property
DefaultAuthenticationMode
Returns AFAuthenticationMode shared by parent collection.
Public property
Description
Read/write property that provides a more detailed description of the object.
Public property
ID
Read-only property that provides a unique identifier for the object to be used for quick access that is not dependent upon the index.
(Inherited from AFObject.)
Public property
Identities
This is the PIIdentity collection of the PIServer.
Public property
Identity
This read-only property contains identity of the object.
(Inherited from AFObject.)
Public property
IdentityMappings
This is the PIIdentityMapping collection of the PIServer.
Public property
IdentityServerAuthorizationEndpoint
Read-only property that returns the Authorization Endpoint for the Identity Server for the . Will match unless connecting to a different RSSO Server.
Public property
IdentityServerEndpointAddress
Read-only property that returns the endpoint address for the Identity Server for the .
Public property
IsDeleted
This read-only property indicates whether the object has been deleted.
(Inherited from AFObject.)
Public property
Name
This property identifies the name of the PIServer.
Public property
PISystem
This read-only property allows access to the PISystem associated with this object.
(Inherited from AFObject.)
Public property
PointClasses
This is the PIPointClass collection of the PIServer.
Public property
PointSources
This is the PIPointSource collection of the PIServer.
Public property
ServerTime
Gets the current time of the PI Data Archive.
Public property
ServerTimeZone
Gets the current time zone of the PI Data Archive.
Public property
ServerVersion
Read-only property that contains a string that uniquely identifies the current server version.
Public property
StateSets
This is the collection of PI Digital State Sets on the PIServer represented as a collection of AFEnumerationSet
Public property
UniqueID
Read-only property that provides the PIServer's unique identifier as a String.
(Overrides AFObjectUniqueID.)
Public property
UsingDefaultAuthenticationMode
Returns true if PISystem is using the default shared AFAuthenticationMode

Methods

  NameDescription
Public method
CompareTo(Object)
Compares this instance with a specified Object.
(Inherited from AFObject.)
Public method
CompareTo(AFObject)
Compares this instance with a specified AFObject.
(Inherited from AFObject.)
Public methodCode example
Connect(Boolean)
Open a connection to the PI Data Archive using default credentials to allow sending and retrieving data.
Public methodCode example
Connect(NetworkCredential)
Open a connection to the PI Data Archive using the specified PI User credentials to allow sending and retrieving data.
Public method
Connect(String)
Connects to the server using the specified Access Token to allow sending and retrieving data.
Public methodCode example
Connect(AFConnectionPreference)
Open a connection to the PI Data Archive using the specified connection preference to allow sending and retrieving data.
Public methodCode example
Connect(Boolean, IWin32Window)
Open a connection to the PI Data Archive with a credential prompt if necessary to allow sending and retrieving data.
Public methodCode example
Connect(NetworkCredential, AFConnectionPreference)
Open a connection to the PI Data Archive using the specified PI User credentials and connection preference to allow sending and retrieving data.
Public methodCode example
Connect(NetworkCredential, PIAuthenticationMode)
Open a connection to the PI Data Archive using the specified credentials to allow sending and retrieving data.
Public method
Connect(String, AFConnectionPreference)
Connects to the server using the specified Access Token to allow sending and retrieving data.
Public method
Connect(String, String)
Connects to the server using the specified credentials to allow sending and retrieving data.
Public methodCode example
Connect(Boolean, IWin32Window, AFConnectionPreference)
Open a connection to the PI Data Archive using the specified connection preference with a credential prompt if necessary to allow sending and retrieving data.
Public methodCode example
Connect(NetworkCredential, AFConnectionPreference, PIAuthenticationMode)
Open a connection to the PI Data Archive using the specified credentials and connection preference to allow sending and retrieving data.
Public method
Connect(String, String, AFConnectionPreference)
Connects to the server using the specified credentials to allow sending and retrieving data.
Public methodCode example
Connect(Boolean, IWin32Window, AFConnectionPreference, Boolean)
Open a connection to the PI Data Archive using the specified connection preference with a credential prompt if necessary to allow sending and retrieving data and return an indication that dialog was canceled.
Public method
ConnectWithPrompt
Connects to the server prompting for credentials.
Public methodCode example
ConnectWithPrompt(IWin32Window)
Open a connection to the PI Data Archive prompting for credentials to allow sending and retrieving data.
Public methodCode example
ConnectWithPrompt(AFConnectionPreference)
Open a connection to the PI Data Archive prompting for credentials to allow sending and retrieving data.
Public methodCode example
ConnectWithPrompt(IWin32Window, PIAuthenticationMode, NullableAFConnectionPreference)
Open a connection to the PI Data Archive prompting for credentials to allow sending and retrieving data.
Public method
CreatePIPoint
Create a new PIPoint on the current PIServer.
Public method
CreatePIPoints(IDictionaryString, IDictionaryString, Object)
Create a list of new PIPoint objects on the current PIServer with each point having a different set of attribute values.
Public method
CreatePIPoints(IEnumerableString, IDictionaryString, Object)
Create a list of new PIPoint objects on the current PIServer with all points having the same attribute values.
Public method
DeletePIPoint
Delete a PIPoint from the PIServer.
Public method
DeletePIPoints
Delete a list of PIPoint objects from the PIServer.
Public method
Disconnect
Close a connection to the PI Data Archive.
Public method
Equals(Object)
Determines whether the specified Object is equal to the current object.
(Overrides AFObjectEquals(Object).)
Public method
Equals(AFObject)
Indicates whether the current object is equal to another object of the same type.
(Inherited from AFObject.)
Public method
Equals(PIServer)
Indicates whether the current object is equal to another object of the same type.
Public method
ExportCsv(Object, IListObject, IListString, CultureInfo)
Exports the CSV representation of requested object(s) and returns it as a string. The supported objects include PI Points, PI DigitalStateSets, PI Identities, or PI IdentityMappings.
Public method
ExportCsv(Object, IListObject, IListString, PIExportMode, CultureInfo)
Exports the CSV representation of requested object(s) and returns it as a string. The supported objects include PI Points, PI DigitalStateSets, PI Identities, or PI IdentityMappings.
Public method
ExportCsv(Object, IListObject, IListString, CultureInfo, String, EventHandlerAFProgressEventArgs)
Exports the representation of requested object(s) in comma-separated (CSV) format to a file. The supported objects include PI Points, PI DigitalStateSets, PI Identities, or PI IdentityMappings.
Public method
ExportCsv(Object, IListObject, IListString, PIExportMode, CultureInfo, String, EventHandlerAFProgressEventArgs)
Exports the representation of requested object(s) in comma-separated (CSV) format to a file. The supported objects include PI Points, PI DigitalStateSets, PI Identities, or PI IdentityMappings.
Public methodCode example
FindChangedPIPoints
Find all the PI Points that have changed in the PIServer.
Public methodStatic member
FindPIServer(Guid)
Find the PIServer from the specified unique identifier.
Public methodStatic member
FindPIServer(String)
Find the PIServer from the specified name.
Public methodStatic member
FindPIServer(PISystem, Guid)
Find the PIServer from the specified unique identifier using the credentials of the current user associated with the specified PISystem.
Public methodStatic member
FindPIServer(PISystem, String)
Find the PIServer from the specified name using the credentials of the current user associated with the specified PISystem.
Public method
GetAnnotations
Gets the annotations associated with list of historical events.
Public method
GetBufferStatus
This method gets the PIBufferStatus for the corresponding PIServer.
Public method
GetClientRpcMetrics
Get the remote procedure call metrics to the server for this PIServer.
Public method
GetCsvColumns(Type, Boolean)
Retrieve a collection containing the required and optional CSV columns for the specified object type and its children. The supported objects include PI Points, PI DigitalStateSets, PI Identities, or PI IdentityMappings.
Public method
GetCsvColumns(Type, IListObject, Boolean)
Retrieve a collection containing the required and optional CSV columns for the specified object type and its children. The supported objects include PI Points, PI DigitalStateSets, PI Identities, or PI IdentityMappings.
Public method
GetHashCode
Gets the hash code for this instance of the object which is suitable for use in hashing algorithms and data structures like a hash table.
(Overrides AFObjectGetHashCode.)
Public method
GetIdentityServerBestRsso
Method to retrieve the Best Redundant Single Sign-On Server Endpoint for the Identity Server for the .
Public method
GetPath
Returns the full path to the object, using just the names.
(Inherited from AFObject.)
Public method
GetPath(AFObject)
Returns the path to the object relative from another object.
(Inherited from AFObject.)
Public method
GetPath(AFEncodeType, AFObject)
Returns the path to the object relative from another object, using the name and/or id as specified by encodeType.
(Inherited from AFObject.)
Public method
GetPointAttributeNames
Get the list of PIPoint attributes names for the PIServer.
Public method
GetPointCount
This method gets the total point count for the corresponding PIServer.
Public method
GetType
Gets the Type of the current instance.
(Inherited from Object.)
Public method
ImportCsv(PIImportMode, CultureInfo, Stream, EventHandlerAFProgressEventArgs)
Imports the comma-separated value (CSV) representation of PI Points, PI DigitalStateSets, PI Identities, or PI IdentityMappings from a stream.
Public method
ImportCsv(PIImportMode, CultureInfo, String, EventHandlerAFProgressEventArgs)
Imports the comma-separated value (CSV) representation of PI Points, PI DigitalStateSets, PI Identities, or PI IdentityMappings from a file.
Public method
LogOut
Logs out the current OIDC user and closes all associated connections to the PI Data Archive.
Public method
Persist
This method returns the persistence string for the object.
(Overrides AFObjectPersist.)
Public method
Refresh
Refresh the cached information for the PIServer.
Public method
RefreshOIDCToken
Refreshes OIDC token on the PI Data Archive. New access token to refresh the connection; if null, will try refresh token if available. This exception will be generated if newAccessToken and refresh token are both unavailable.
Public method
ReplaceValues(AFTimeRange, IListAFValues)
This method removes existing data within the specified AFTimeRange and inserts the specified values.
Public method
ReplaceValues(AFTimeRange, IListAFValues, AFBufferOption)
This method removes existing data within the specified AFTimeRange and inserts the specified values.
Public method
Supports
Checks if the specified PIServerFeature feature is supported by the PIServer.
Public method
ToString
Returns a String that represents the current object.
(Inherited from AFObject.)
Public methodStatic member
TryConvertToServerID
Convert a string key to a PIServer ID.
Public method
UpdateValues(IListAFValue, AFUpdateOption)
Update, write or delete the PIPoint value for each AFValue in the specified list.
Public methodCode example
UpdateValues(IListAFValue, AFUpdateOption, AFBufferOption)
Update the PIPoint value for each AFValue in the specified list.
Public method
UpdateValuesAsync(IListAFValue, AFUpdateOption, CancellationToken)
Update the PIPoint value for each AFValue in the specified list.
Public method
UpdateValuesAsync(IListAFValue, AFUpdateOption, AFBufferOption, CancellationToken)
Update the PIPoint value for each AFValue in the specified list.

Events

  NameDescription
Public eventCode example
Changed
Event is raised when the object or one of its sub-objects is changed.
Public eventCode example
ConnectChanged
Occurs when the connection status of this PIServer changes.

Operators

  NameDescription
Public operatorStatic member
Equality
The equality operator (==) compares its operands to determine if they are equal.
Public operatorStatic member
Inequality
The inequality operator (!=) compares its operands to determine if they are not equal.

Fields

  NameDescription
Public field
SelectedAuthenticationMode
Get the PIAuthenticationMode used to connect to the PI Server

Remarks

The PIServer object manages the connection to a PI Data Archive and provides access to the basic entities represented on each PI Data Archive. Use one of the FindPIServer Overload methods to obtain a PIServer object.

Typically a program will require a network connection to the PI Data Archive. Connections are established either by calling one of the Connect Overload methods explicitly, or by accessing a property or calling a method that requires server access.

Note Notes to Callers
This method, property, or class is not available in the legacy .NET 3.5 version of the SDK.

Examples

PIServers myPIServers = new PIServers();

// Display information for Default PIServer
PIConnectionInfo myConnectionInfo = myPIServers.DefaultPIServer.ConnectionInfo;
Console.WriteLine("Name of Default PIServer = {0}", myPIServers.DefaultPIServer.Name);
Console.WriteLine("Host used to connect to Default PIServer = {0}", myConnectionInfo.Host);
Console.WriteLine("Port used to connect to Default PIServer = {0}", myConnectionInfo.Port);
Console.WriteLine();

// Display the number of PIServers
Console.WriteLine("PIServer count = {0}", myPIServers.Count);

// Display PIServer information
foreach (PIServer server in myPIServers)
{
    Console.WriteLine("   Name of PIServer = {0}", server.Name);
    if (server.UniqueID != "")
        Console.WriteLine("   UniqueID of PIServer = {0}", server.UniqueID);
    else
        Console.WriteLine("   UniqueID of PIServer = n/a");
    if (server.ServerVersion != "")
        Console.WriteLine("   Version of PIServer = {0}", server.ServerVersion);
    else
        Console.WriteLine("   Version of PIServer = n/a");
    Console.WriteLine();
}

// Get the PIServer on the specified computer
PIServer myPIServer = PIServer.FindPIServer(piServerName);

// Display information about the PIServer
Console.WriteLine("Name of the local PIServer = {0}", myPIServer.Name);
Console.WriteLine("ID of the PIServer = {0}", myPIServer.ID);
Console.WriteLine("PIServer Current Time = {0}", myPIServer.ServerTime);
Console.WriteLine("PIServer TimeZone = {0}", myPIServer.ServerTimeZone);
Console.WriteLine();

// Remove PIServer if it exists
if (myPIServers["NewPIServer"] != null)
{
    myPIServers.Remove("NewPIServer");
}

// Add a new PIServer without validating host address
PIServers.DirectoryOptions = PISystems.AFDirectoryOptions.None;
PIServer newPIServer = myPIServers.Add("NewPIServer");
newPIServer.ConnectionInfo.Host = "NewHostAddress";
Dim myPIServers As New PIServers()

' Display information for Default PIServer
Dim myConnectionInfo As PIConnectionInfo = myPIServers.DefaultPIServer.ConnectionInfo
Console.WriteLine("Name of Default PIServer = {0}", myPIServers.DefaultPIServer.Name)
Console.WriteLine("Host used to connect to Default PIServer = {0}", myConnectionInfo.Host)
Console.WriteLine("Port used to connect to Default PIServer = {0}", myConnectionInfo.Port)
Console.WriteLine()

' Display the number of PIServers
Console.WriteLine("PIServer count = {0}", myPIServers.Count)

' Display PIServer information
For Each server As PIServer In myPIServers
    Console.WriteLine("   Name of PIServer = {0}", server.Name)
    If server.UniqueID <> "" Then
        Console.WriteLine("   UniqueID of PIServer = {0}", server.UniqueID)
    Else
        Console.WriteLine("   UniqueID of PIServer = n/a")
    End If
    If server.ServerVersion <> "" Then
        Console.WriteLine("   Version of PIServer = {0}", server.ServerVersion)
    Else
        Console.WriteLine("   Version of PIServer = n/a")
    End If
    Console.WriteLine()
Next

' Get the PIServer on the specified computer
Dim myPIServer As PIServer = PIServer.FindPIServer(piServerName)

' Display information about the PIServer
Console.WriteLine("Name of the local PIServer = {0}", myPIServer.Name)
Console.WriteLine("ID of the PIServer = {0}", myPIServer.ID)
Console.WriteLine("PIServer Current Time = {0}", myPIServer.ServerTime)
Console.WriteLine("PIServer TimeZone = {0}", myPIServer.ServerTimeZone)
Console.WriteLine()

' Remove PIServer if it exists
If myPIServers("NewPIServer") IsNot Nothing Then
    myPIServers.Remove("NewPIServer")
End If

' Add a new PIServer without validating host address
PIServers.DirectoryOptions = PISystems.AFDirectoryOptions.None
Dim newPIServer As PIServer = myPIServers.Add("NewPIServer")
newPIServer.ConnectionInfo.Host = "NewHostAddress"

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

Version Information

AFSDK


See Also

TitleResults for “How to create a CRG?”Also Available in