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

PI Powershell

ConnectAFServer Class

  • Last UpdatedDec 15, 2025
  • 4 minute read
ConnectAFServer Class

Connect to an AF Server

The Connect-AFServer cmdlet will connect to an AF Server in the local AF Servers list.

Inheritance Hierarchy

SystemObject
  InternalCommand
    Cmdlet
      PSCmdlet
        OSIsoft.PowerShellOSICmdletBase
          OSIsoft.PowerShellConnectAFServer

Namespace:  OSIsoft.PowerShell
Assembly:  OSIsoft.PowerShell (in OSIsoft.PowerShell.dll) Version: 3.1.1.0 (3.1.1.466)

Syntax

[CmdletAttribute("Connect", "AFServer", SupportsShouldProcess = true)]
public class ConnectAFServer : OSICmdletBase
<CmdletAttribute("Connect", "AFServer", SupportsShouldProcess := true)>
Public Class ConnectAFServer
	Inherits OSICmdletBase

Dim instance As ConnectAFServer
[CmdletAttribute(L"Connect", L"AFServer", SupportsShouldProcess = true)]
public ref class ConnectAFServer : public OSICmdletBase
[<CmdletAttribute("Connect", "AFServer", SupportsShouldProcess = true)>]
type ConnectAFServer =  
    class
        inherit OSICmdletBase
    end

The ConnectAFServer type exposes the following members.

Constructors

  NameDescription
Public method
ConnectAFServer

Properties

  NameDescription
Public property
AccessToken

Access token to use when connecting to the AF Server

Public property
AFConnectionPreference

Defines the connection preference when connecting to an AF Server which is in an HA Collective. If not specified, PreferPrimary is the default.

Public property
AFServer

AFServer object representing the AF Server to connect to

Public property
ClientCredential

Client id and secret to get access token to use when connecting to the AF Server

Public property
PromptForAccessToken

Browser popup to authorize getting access token to use when connecting to the AF Server

Public property
WindowsCredential

Windows credential to use when connecting to the AF Server

Examples

Connect-AFServer -AFServer (Get-AFServer -Default)

This example will connect to the default AF Server in the local AF Servers list.

Examples

Connect-AFServer -WindowsCredential (Get-Credential TestDomain\TestUser) -AFServer (Get-AFServer -Name PIAF1)

This example will connect to the AF Server "PIAF1" with the credentials TestDomain\TestUser. Upon running the command, the user will be prompted for the password of the TestDomain\TestUser account. If -WindowsCredential is not specified, then the credentials of the user running PowerShell will be used.

Examples

Connect-AFServer -AFConnectionPreference Any -AFServer (Get-AFServer -Default)

This example will connect to the default AF Server with the connection preference "Any" if it is an AF Collective.

Examples

Connect-AFServer -PromptForAccessToken -AFServer (Get-AFServer -Default)

This example will connect to the default AF Server after the user authorizes it using the browser.

Examples

$credential = [PSCredential]::New('clientid', (ConvertTo-SecureString 'clientsecret' -AsPlainText -Force));
Connect-AFServer -ClientCredential $credential -AFServer (Get-AFServer -Default)

This example will connect to the default AF Server using a client id and secret.

See Also

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