Connect-VIServer

This cmdlet establishes a connection to a vCenter Server system. The cmdlet starts a new session or re-establishes a previous session with a vCenter Server system using the specified parameters.

Syntax

-Server  <String[]>
[-AllLinked]
[-Credential  <PSCredential>]
[-Force]
[-NotDefault]
[-Password  <String>]
[-Port  <Int32>]
[-Protocol  <String>]
[-SaveCredentials]
[-Session  <String>]
[-User  <String>]
[CommonParameters]

Parameters

Required Parameter Name Type Position Features Description
required
Server
String[] named
  • wildcards
  • Specifies the IP address or the DNS name of the vSphere server to which you want to connect. You can also specify a server by providing its IPv6 address enclosed in square brackets, for example [fe80::250:56ff:feb0:74bd%4].
    optional
    AllLinked
    SwitchParameter named Indicates whether you want to connect to vCenter Server in linked mode. If you specify $true for the AllLinked parameter and the server to which you want to connect is a part of a federation vCenter Server, you'll be connected to all members of the linked vCenter Server.
    optional
    Credential
    PSCredential named
  • pipeline
  • Specifies a PSCredential object that contains credentials for authenticating with the server. For more information about the server authentication logic of PowerCLI, run "help about_server_authentication". Passing values to this parameter through a pipeline is deprecated and will be disabled in a future release.
    optional
    Force
    SwitchParameter named Suppresses all user interface prompts during the cmdlet execution. Currently, these include 'Multiple default servers' and 'Invalid certificate action'.
    optional
    NotDefault
    SwitchParameter named Indicates that you do not want to include the server to which you connect into the $defaultVIServers variable.
    optional
    Password
    String named Specifies the password you want to use for authenticating with the server. If the Credential parameter is also specified, this parameter is ignored. For more information about the server authentication logic of PowerCLI, run "help about_server_authentication".
    optional
    Port
    Int32 named Specifies the port on the server you want to use for the connection.
    optional
    Protocol
    String named Specifies the Internet protocol you want to use for the connection. It can be either http or https.
    optional
    SaveCredentials
    SwitchParameter named Indicates that you want to save the specified credentials in the local credential store.
    optional
    Session
    String named Specifies the ID of an existing vCenter Server session you want to re-establish.
    optional
    User
    String named
  • pipeline
  • Specifies the user name you want to use for authenticating with the server. If the Credential parameter is also specified, this parameter is ignored. For more information about the server authentication logic of PowerCLI, run "help about_server_authentication". Passing values to this parameter through a pipeline is deprecated and will be disabled in a future release.

    -Menu
    [CommonParameters]

    Parameters

    Required Parameter Name Type Position Features Description
    required
    Menu
    SwitchParameter named Indicates that you want to select a connection server from a list of recently connected servers. If Menu is set to $true, the cmdlet retrieves a list of the last visited servers and enters a nested command prompt, so that you can select a server from the list.

    -SamlSecurityContext  <SamlSecurityContext>
    -Server  <String[]>
    [-AllLinked]
    [-Force]
    [-NotDefault]
    [-Port  <Int32>]
    [-Protocol  <String>]
    [CommonParameters]

    Parameters

    Required Parameter Name Type Position Features Description
    required
    SamlSecurityContext
    SamlSecurityContext named
  • pipeline
  • Specifies the SAML2 security context for the vCenter Server system. For more information about security contexts, see the about_security_context (about_security_context.html)article.
    required
    Server
    String[] named
  • wildcards
  • Specifies the IP address or the DNS name of the vSphere server to which you want to connect. You can also specify a server by providing its IPv6 address enclosed in square brackets, for example [fe80::250:56ff:feb0:74bd%4].
    optional
    AllLinked
    SwitchParameter named Indicates whether you want to connect to vCenter Server in linked mode. If you specify $true for the AllLinked parameter and the server to which you want to connect is a part of a federation vCenter Server, you'll be connected to all members of the linked vCenter Server.
    optional
    Force
    SwitchParameter named Suppresses all user interface prompts during the cmdlet execution. Currently, these include 'Multiple default servers' and 'Invalid certificate action'.
    optional
    NotDefault
    SwitchParameter named Indicates that you do not want to include the server to which you connect into the $defaultVIServers variable.
    optional
    Port
    Int32 named Specifies the port on the server you want to use for the connection.
    optional
    Protocol
    String named Specifies the Internet protocol you want to use for the connection. It can be either http or https.

    Output

    VMware.VimAutomation.ViCore.Types.V1.VIServer

    Examples


    Example 1

    Connect-VIServer -Server 10.23.112.235 -Protocol https -User admin -Password pass

    Connects to a vSphere server by using the User and Password parameters.

    Example 2

    Connect-VIServer Server -Credential $myCredentialsObject -Port 1234

    Connects to a vSphere server by using a credential object.

    Example 3

    Connect-VIServer "Server" -SessionId $sessionId

    Connects by using a server session ID. Once you connect to a server, you can save the session ID - $serverObject.SessionId, so that you can restore the existing server connection instead of reconnecting.

    Example 4

    Connect-VIServer Server

    Connects by using integrated authentication. In this case, the credentials you are logged on to your machine must be the same as those for the server.

    Example 5

    Connect-VIServer "Server" -User user -Password pass -SaveCredentials

    Connects to a server and save the credentials in the credential store. After the credentials are stored, you can connect to the server without specifying them. To get a previously saved credential store item, use the Get-VICredentialStoreItem cmdlet.

    Example 6

    Connect-VIServer -Menu

    Connects to a server by choosing the server address from a list of previously connected servers.

    Example 7

    Connect-VIServer "Server" -AllLinked

    Connects to a vSphere server which is a part of a federation vCenter Server system. This will connect you to all vSphere servers in the federation as well.

    Example 8

    $oauthCtx = New-VcsOAuthSecurityContext -ApiToken "a3f35067-80b5-44f0-a0bc-e19f2bc17fb7"
    $samlCtx = New-VISamlSecurityContext -VCenterServer "Server" -OAuthSecurityContext $oauthCtx
    Connect-VIServer -Server "Server" -SamlSecurityContext $samlCtx

    Connects to a vCenter server that runs in a VMware managed cloud using an API token from the VMware Cloud Services portal.

    Related Commands

    Feedback

    Was this page helpful?