< Back
Connect-VIServer
Post
NAME Connect-VIServer
SYNOPSIS
This cmdlet establishes a connection to a vCenter Server system.
SYNTAX
Connect-VIServer [-Server] <String[]> [-AllLinked] [-Credential <PSCredential>] [-Force] [-NotDefault] [-Password
<String>] [-Port <Int32>] [-Protocol {http | https}] [-SaveCredentials] [-Session <String>] [-User <String>]
[<CommonParameters>]
Connect-VIServer [-Server] <String[]> [-AllLinked] [-Force] [-NotDefault] [-Port <Int32>] [-Protocol {http |
https}] -SamlSecurityContext <SamlSecurityContext> [<CommonParameters>]
Connect-VIServer -Menu [<CommonParameters>]
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.
When you attempt to connect to a server, the server checks for valid certificates. To set the default behavior of
VMware PowerCLI when no valid certificates are recognized, use the InvalidCertificateAction parameter of the
Set-PowerCLIConfiguration cmdlet. For more information about invalid certificates, run 'Get-Help
about_invalid_certificates'.
You can have more than one connection to the same server. To disconnect from a server, you need to close all
active connections to this server. VMware PowerCLI supports working with multiple default servers. If you select
this option, every time when you connect to a different server by using the Connect-VIServer cmdlet, the new
server connection is stored in an array variable together with the previously connected servers, unless the
NotDefault parameter is set. This variable is named $DefaultVIServers 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 server from the $DefaultVIServers variable, you can
either use the Disconnect-Server cmdlet 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
determined 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 the DefaultServerMode parameter of the
Set-PowerCLIConfiguration cmdlet. Working with multiple default servers will be enabled by default in a future
release.
PARAMETERS
-AllLinked [<SwitchParameter>]
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.
To use this option, PowerCLI must be configured to work in multiple servers connection mode. To configure
PowerCLI to support multiple servers connection, specify Multiple for the DefaultVIServerMode parameter of the
Set-PowerCLIConfiguration cmdlet.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-Credential <PSCredential>
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.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? false
-Force [<SwitchParameter>]
Suppresses all user interface prompts during the cmdlet execution. Currently, these include 'Multiple default
servers' and 'Invalid certificate action'.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-Menu [<SwitchParameter>]
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.
Required? true
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-NotDefault [<SwitchParameter>]
Indicates that you do not want to include the server to which you connect into the $defaultVIServers variable.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-Password <String>
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".
Note: If the password contains special characters, enclose the entire string in single quotes (').
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Port <Int32>
Specifies the port on the server you want to use for the connection.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Protocol <String>
Specifies the Internet protocol you want to use for the connection. It can be either http or https.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-SamlSecurityContext <SamlSecurityContext>
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? true
Position? named
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? false
-SaveCredentials [<SwitchParameter>]
Indicates that you want to save the specified credentials in the local credential store.
Note: This parameter is not supported on the Core edition of PowerShell.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-Server <String[]>
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].
Required? true
Position? 1
Default value None
Accept pipeline input? False
Accept wildcard characters? true
-Session <String>
Specifies the ID of an existing vCenter Server session you want to re-establish.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-User <String>
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.
Note: If the user name contains special characters, enclose the entire string in single quotes (').
Required? false
Position? named
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
VIServer
NOTES
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.
-------------------------- 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 LINKS
Online Version: https://code.vmware.com/doc/preview?id= ... erver.html
Disconnect-VIServer
CommonParameters : False
WorkflowCommonParameters : False
details : @{name=Get-PowerCLIHelp; noun=; verb=}
Syntax : @{syntaxItem=System.Object[]}
parameters : @{parameter=System.Object[]}
inputTypes : @{inputType=}
returnValues : @{returnValue=}
aliases : Get-PowerCLIDocumentation
remarks : None
alertSet :
description :
examples :
Synopsis :
Get-PowerCLIHelp
ModuleName : VMware.VimAutomation.Sdk
nonTerminatingErrors :
xmlns:command : http://schemas.microsoft.com/maml/dev/command/2004/10
xmlns:dev : http://schemas.microsoft.com/maml/dev/2004/10
xmlns:maml : http://schemas.microsoft.com/maml/2004/10
Name : Get-PowerCLIHelp
Category : Function
Component :
Role :
Functionality :
SYNOPSIS
This cmdlet establishes a connection to a vCenter Server system.
SYNTAX
Connect-VIServer [-Server] <String[]> [-AllLinked] [-Credential <PSCredential>] [-Force] [-NotDefault] [-Password
<String>] [-Port <Int32>] [-Protocol {http | https}] [-SaveCredentials] [-Session <String>] [-User <String>]
[<CommonParameters>]
Connect-VIServer [-Server] <String[]> [-AllLinked] [-Force] [-NotDefault] [-Port <Int32>] [-Protocol {http |
https}] -SamlSecurityContext <SamlSecurityContext> [<CommonParameters>]
Connect-VIServer -Menu [<CommonParameters>]
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.
When you attempt to connect to a server, the server checks for valid certificates. To set the default behavior of
VMware PowerCLI when no valid certificates are recognized, use the InvalidCertificateAction parameter of the
Set-PowerCLIConfiguration cmdlet. For more information about invalid certificates, run 'Get-Help
about_invalid_certificates'.
You can have more than one connection to the same server. To disconnect from a server, you need to close all
active connections to this server. VMware PowerCLI supports working with multiple default servers. If you select
this option, every time when you connect to a different server by using the Connect-VIServer cmdlet, the new
server connection is stored in an array variable together with the previously connected servers, unless the
NotDefault parameter is set. This variable is named $DefaultVIServers 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 server from the $DefaultVIServers variable, you can
either use the Disconnect-Server cmdlet 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
determined 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 the DefaultServerMode parameter of the
Set-PowerCLIConfiguration cmdlet. Working with multiple default servers will be enabled by default in a future
release.
PARAMETERS
-AllLinked [<SwitchParameter>]
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.
To use this option, PowerCLI must be configured to work in multiple servers connection mode. To configure
PowerCLI to support multiple servers connection, specify Multiple for the DefaultVIServerMode parameter of the
Set-PowerCLIConfiguration cmdlet.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-Credential <PSCredential>
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.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? false
-Force [<SwitchParameter>]
Suppresses all user interface prompts during the cmdlet execution. Currently, these include 'Multiple default
servers' and 'Invalid certificate action'.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-Menu [<SwitchParameter>]
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.
Required? true
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-NotDefault [<SwitchParameter>]
Indicates that you do not want to include the server to which you connect into the $defaultVIServers variable.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-Password <String>
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".
Note: If the password contains special characters, enclose the entire string in single quotes (').
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Port <Int32>
Specifies the port on the server you want to use for the connection.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Protocol <String>
Specifies the Internet protocol you want to use for the connection. It can be either http or https.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-SamlSecurityContext <SamlSecurityContext>
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? true
Position? named
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? false
-SaveCredentials [<SwitchParameter>]
Indicates that you want to save the specified credentials in the local credential store.
Note: This parameter is not supported on the Core edition of PowerShell.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-Server <String[]>
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].
Required? true
Position? 1
Default value None
Accept pipeline input? False
Accept wildcard characters? true
-Session <String>
Specifies the ID of an existing vCenter Server session you want to re-establish.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-User <String>
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.
Note: If the user name contains special characters, enclose the entire string in single quotes (').
Required? false
Position? named
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
VIServer
NOTES
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.
-------------------------- 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 LINKS
Online Version: https://code.vmware.com/doc/preview?id= ... erver.html
Disconnect-VIServer
CommonParameters : False
WorkflowCommonParameters : False
details : @{name=Get-PowerCLIHelp; noun=; verb=}
Syntax : @{syntaxItem=System.Object[]}
parameters : @{parameter=System.Object[]}
inputTypes : @{inputType=}
returnValues : @{returnValue=}
aliases : Get-PowerCLIDocumentation
remarks : None
alertSet :
description :
examples :
Synopsis :
Get-PowerCLIHelp
ModuleName : VMware.VimAutomation.Sdk
nonTerminatingErrors :
xmlns:command : http://schemas.microsoft.com/maml/dev/command/2004/10
xmlns:dev : http://schemas.microsoft.com/maml/dev/2004/10
xmlns:maml : http://schemas.microsoft.com/maml/2004/10
Name : Get-PowerCLIHelp
Category : Function
Component :
Role :
Functionality :