PIServers Class
- Last UpdatedNov 18, 2025
- 11 minute read
- PI System
- AF SDK 2024 R2
- Developer
The global collection of PIServer objects
that represents the known PI Data Archive servers available from
a workstation for client applications.

Inheritance Hierarchy
SystemObject
OSIsoft.AF.PIPIServers
OSIsoft.AF.PIPIServers
Namespace: OSIsoft.AF.PI
Assembly: OSIsoft.AFSDK (in OSIsoft.AFSDK.dll) Version: 3.1.1.1182
Syntax
public sealed class PIServers : IList<PIServer>, ICollection<PIServer>, IEnumerable<PIServer>, IEnumerable, IAFList, IList, ICollection, IAFChangedEvent
Public NotInheritable Class PIServers Implements IList(Of PIServer), ICollection(Of PIServer), IEnumerable(Of PIServer), IEnumerable, IAFList, IList, ICollection, IAFChangedEvent Dim instance As PIServers
public ref class PIServers sealed : IList<PIServer^>, ICollection<PIServer^>, IEnumerable<PIServer^>, IEnumerable, IAFList, IList, ICollection, IAFChangedEvent
[<SealedAttribute>] type PIServers = class interface IList<PIServer> interface ICollection<PIServer> interface IEnumerable<PIServer> interface IEnumerable interface IAFList interface IList interface ICollection interface IAFChangedEvent end
The PIServers type exposes the following members.
Constructors
| Name | Description | |
|---|---|---|
| PIServers |
Initializes a new instance of the PIServers collection.
|
Properties
| Name | Description | |
|---|---|---|
| AuthenticationOptions |
The authentication options used when making a connection to a PIServer.
| |
| Count |
Gets the number of items actually contained in the collection.
| |
| DefaultPIServer |
The default PIServer configured for the current client machine.
| |
| DirectoryOptions |
The directory options used when looking up a PIServer in the collection.
| |
| Identity |
This read-only property contains identity of the object.
| |
| ItemGuid |
Gets the item with the specified id.
| |
| ItemInt32 |
Gets or sets the item at the specified index.
| |
| ItemString |
Returns the specified object from the collection by name.
|
Methods
| Name | Description | |
|---|---|---|
| Add |
Registers a new PIServer to the list of known servers on the local machine.
| |
| Clear |
Unregisters all existing PIServer entries from the list of known
PI Data Archive servers on the local machine.
| |
| Contains(Guid) |
This method determines whether the collection contains a specific item referenced by id.
| |
| Contains(String) |
This method determines whether the collection contains a specific item referenced by name.
| |
| Contains(PIServer) |
This method determines whether the collection contains a specific item.
| |
| CopyTo |
Copies the entire collection to a compatible one-dimensional Array,
starting at the specified index of the target array.
| |
| DisconnectAll |
Disconnects all PIServers that are currently connected.
| |
| Equals |
Determines whether the specified Object is equal to the current object.
(Overrides ObjectEquals(Object).) | |
| GetBufferStatus |
This method gets the PIBufferStatus of the PI Buffer Subsystem.
| |
| GetEnumerator |
Returns an enumerator that iterates through the collection.
| |
| 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 ObjectGetHashCode.) | |
| GetPIServers(PISystem) |
Get the list of known PIServers on the local machine.
| |
| GetPIServers(ClaimsIdentity, Boolean) |
Get the list of known PIServers on the local machine.
| |
| GetPIServers(String, String, Boolean) |
Get the list of known PIServers on the local machine.
| |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| IndexOf |
Searches for the specified object and returns the zero-based index of the first
occurrence within the entire collection.
| |
| Refresh |
Refresh the list of known PI Data Archive servers on the local machine,
where the cached collections of connected servers will be refreshed.
| |
| Refresh(Boolean) |
Refresh the list of known PI Data Archive servers on the local machine
with the option to refresh cached collections for connected servers.
| |
| Remove(Guid) |
Unregisters an existing PIServer with the specified unique identifier.
| |
| Remove(String) |
Unregisters an existing PIServer with the specified name.
| |
| Remove(PIServer) |
Unregisters the specified PIServer.
| |
| RemoveAt |
Unregisters an existing PIServer by removing the entry from the list of known
PI Data Archive servers on the local machine.
| |
| Sort |
Sorts the items in the entire collection using the default comparer.
| |
| Sort(IComparerPIServer) |
Sorts the items in the entire collection using the specified comparer.
| |
| Sort(Int32, Int32, IComparerPIServer) |
Sorts the items in a range of items in the collection using the specified comparer.
| |
| ToString |
Returns a String that represents the current object.
(Overrides ObjectToString.) |
Events
| Name | Description | |
|---|---|---|
| Changed |
Event is raised when the object or one of its sub-objects is changed.
| |
| ConnectFailed |
Occurs when the connection to a PIServer fails and not performing
an auto prompt.
|
Operators
| Name | Description | |
|---|---|---|
| Equality |
The equality operator (==) compares its operands to determine if they are equal.
| |
| Inequality |
The inequality operator (!=) compares its operands to determine if they are not equal.
|
Extension Methods
| Name | Description | |
|---|---|---|
| AggregatePIServer |
Performs all requested aggregates on the specified items.
(Defined by AFAggregate.) | |
| AggregateAsyncPIServer |
Performs all requested aggregates on the specified items asynchronously.
(Defined by AFAggregate.) | |
| BinnedSummaryPIServer, TBin |
Generates a summary broken down by the specified bins for items matching the search criteria.
(Defined by AFAggregate.) | |
| BinnedSummaryAsyncPIServer, TBin |
Generates a summary broken down by the specified bins for items matching the search criteria asynchronously.
(Defined by AFAggregate.) | |
| ChunkedByPIServer |
This extension method breaks up search results into chunks to make it easier to
page through and process IEnumerableT collections in chunks.
(Defined by AFSDKExtension.) | |
| FrequencyDistributionPIServer |
Generates a frequency distribution for the specified items.
(Defined by AFAggregate.) | |
| FrequencyDistributionAsyncPIServer |
Generates a frequency distribution for the specified items asynchronously.
(Defined by AFAggregate.) | |
| GroupedSummaryPIServer |
Generates a summary broken down by group for the specified items.
(Defined by AFAggregate.) | |
| GroupedSummaryAsyncPIServer |
Generates a histogram for the specified items asynchronously.
(Defined by AFAggregate.) | |
| HistogramPIServer, TBin |
Generates a histogram for the specified items with the specified weighting.
(Defined by AFAggregate.) | |
| HistogramAsyncPIServer, TBin |
Generates a histogram for the specified items with the specified weighting asynchronously.
(Defined by AFAggregate.) | |
| SummaryPIServer(String, AFSummaryTypes) | Overloaded.
Summarizes the specified items.
(Defined by AFAggregate.) | |
| SummaryPIServer(String, AFSummaryTypes, String) | Overloaded.
Summarizes the specified items with the specified weighting.
(Defined by AFAggregate.) | |
| SummaryAsyncPIServer(String, AFSummaryTypes, CancellationToken) | Overloaded.
Summarizes the specified items asynchronously.
(Defined by AFAggregate.) | |
| SummaryAsyncPIServer(String, AFSummaryTypes, String, CancellationToken) | Overloaded.
Summarizes the specified items with the specified weighting asynchronously.
(Defined by AFAggregate.) |
Remarks
This is the list of known PIServers on the workstation for client
applications. This list of PIServers can be manipulated with the methods of
this object. For example, the Add(String) method is used to add a
PIServer to this workstation. This allows the client to connect to an
existing PIServer that was previously installed on the network.
The DirectoryOptions controls the behavior when looking
up items in the collection.
| 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.