ConnectAFServer Class
- Last UpdatedDec 15, 2025
- 4 minute read
Connect to an AF Server
The Connect-AFServer cmdlet will connect to an AF Server in the local AF Servers list.
Inheritance Hierarchy
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
| Name | Description | |
|---|---|---|
| ConnectAFServer |
Properties
| Name | Description | |
|---|---|---|
| AccessToken | Access token to use when connecting to the AF Server | |
| AFConnectionPreference | Defines the connection preference when connecting to an AF Server which is in an HA Collective. If not specified, PreferPrimary is the default. | |
| AFServer | AFServer object representing the AF Server to connect to | |
| ClientCredential | Client id and secret to get access token to use when connecting to the AF Server | |
| PromptForAccessToken | Browser popup to authorize getting access token to use when connecting to the AF Server | |
| 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.