powershellscripts.com

Tutorials  PowerShell Cmdlet Help for Connect-VIServer



NAME
Connect-VIServer

SYNOPSIS
Connects to a vSphere server.

SYNTAX
Connect-VIServer [-Server] [-Port ] [-Protocol ] [-Credential ] [-User ing>] [-Password ] [-Session ] [-NotDefault] [-SaveCredentials] [-AllLinked] []

Connect-VIServer -Menu []


DESCRIPTION
Connects to a vSphere server. The cmdlet starts a new session or re-establishes a previous session with a vSphere
server using the specified parameters.
You can have more than one connections to the same server. To disconnect from a server, you need to close all activ
e connections to this server.
vSphere PowerCLI supports working with multiple default servers. If you select this option, every time when you con
nect to a different server using Connect-VIServer, the new server connection is stored in an array variable togethe
r with the previously connected servers, unless the -NotDefault parameter is set. This variable is named $DefaultV
IServers and its initial value is an empty array. When you run a cmdlet and the target servers cannot be determined
from the specified parameters, the cmdlet runs against all servers stored in the array variable. To remove a serve
r from the $DefaultVIServers variable, you can either use Disconnect-Server to close all active connections to the
server, or modify the value of $DefaultVIServers manually.

If you choose to work with a single default server, when you run a cmdlet and the target servers cannot be determin
ed from the specified parameters, the cmdlet runs against the last connected server. This server is stored in the $
defaultVIServer variable, which is updated every time you establish a new connection.

To switch between single and multiple default servers working mode, use DefaultServerMode parameter of the Set-Powe
rCLIConfiguration cmdlet. Working with multiple default servers will be enabled by defult in a future release.


PARAMETERS
-Server
Specify 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].

Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? true

-Port
Specify the port on the server you want to use for the connection.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Protocol
Specify the internet protocol you want to use for the connection. It can be either http or https.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Credential
Specify a PSCredential object that contains credentials for authenticating with the server. For more informatio
n 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.

Required? false
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false

-User
Specify 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, r
un "help about_server_authentication". Passing values to this parameter through a pipeline is deprecated and wi
ll be disabled in a future release.

Required? false
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false

-Password
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".

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Session
Specify the ID of an existing vSphere server session you want to reestablish.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-NotDefault
Indicate that you do not want to include the server to which you connect into the $defaultVIServers variable.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-SaveCredentials
Indicate that you want to save the specified credentials in the local credential store.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-AllLinked
Indicate whether you want to connect to vCenter Server in linked mode. If you specify $true for the AllLinked p
arameter and the server to which you want to connect is a part of a federation vCenter Server, you'll be connec
ted to all members of the linked vCenter Server.

To use this option, PowerCLI must be configured to work in multiple servers connection mode. To configure Power
CLI to support multiple servers connection, specify Multiple for the DefaultVIServerMode parameter of the Set-P
owerCLI Configuration cmdlet.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Menu
Indicate 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 y
ou can select a server from the list.

Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false


This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

INPUTS



OUTPUTS
VIServer


NOTES


When you connect to a server via Connect-ViServer you allocate resources on this server, and these resources re
main opened until Disconnect-ViServer -Force is called on this connection. Closing the PowerCLI process does no
t close the server resources.

-------------- EXAMPLE 1 --------------

C:\PS>Connect-VIServer -Server 10.23.112.235 -Protocol https -User admin -Password pass


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





-------------- EXAMPLE 2 --------------

C:\PS>Connect-VIServer Server -Credentials $myCredentialsObject -Port 1234


Connects to a vSphere server by using a credential object.





-------------- Example 3 --------------

C:\PS>Connect-VIServer "Server" -SessionId $sessionId


Connect 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 ex
isting server connection instead of reconnecting.





-------------- Example 4 --------------

C:\PS>Connect-VIServer Server


Connect 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 --------------

C:\PS>Connect-VIServer "Server" -User user -Password pass -SaveCredentials


Connect to a server and save the credentials in the credential store. After the credentials are stored, you can con
nect to the server without specifying them. To get a previously saved credential store item, use the Get-VICredenti
alStoreItem cmdlet.





-------------- Example 6 --------------

C:\PS>Connect-VIServer -Menu


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





-------------- Example 7 --------------

C:\PS>Connect-VIServer "Server" -AllLinked


Connect to a vSphere server which is a part of a federation vCenter Server. This will Connect you to all vSphere se
rvers in the federation as well.






RELATED LINKS
Online version: http://www.vmware.com/support/developer/PowerCLI/PowerCLI501/html/Connect-VIServer.html
Disconnect-VIServer