Syntax
Connect-VIServer [-Server] <String[]> [-AllLinked] [-Credential <PSCredential>] [-Force] [-NotDefault] [-Password <String>] [-Port <Int32>] [-Protocol {http | https}] [-SaveCredentials] [-Session <String>] [-User <String>] [<CommonParameters>]Related Commands
Online VersionDetailed Description
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.Parameters
Return Type
VIServerNotes
When you connect to a server by using the Connect-VIServer cmdlet, you allocate resources on this server, and these resources remain opened until the Force parameter of the Disconnect-VIServer cmdlet is called on this connection. Closing the PowerCLI process does not close the server resources.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.