For example, to power on a virtual machine using the vmcontrol.pl utility application, you must specify the name of the virtual machine to power on, as follows:
Run any application or sample without any options or with --help to see its parameters and execution examples. Information about common and script-specific options is included.
You use the --psc option and, optionally, the
--server option.
The save_session.pl script in the
apps/session directory illustrates how to create a session file. You can modify the script and include it in your own application, or create a session file using the script on the command line, and then pass in that session file when running vSphere SDK for Perl commands. See
Saving Sessions.
You can use the code in the \apps\session\save_session.pl utility application inside your own vSphere SDK for Perl application. If a call to the server throws an exception, your application should terminate the session to avoid session leaks. You could do this with an error handler that runs
disconnect() or
logout(), for example:
You can also use the _END_ pseudo-signal handler to perform a disconnect, as follows:
The following example connects to the server as user snow-white with password
dwarf$. The first example (Linux) uses an escape character before each special character, the other examples use single quotes (Linux) and double quotes (Windows).
The following example shows the contents of a /root/.visdkrc file that uses environment variables:
You can use the --config option to run a script with the configuration file, for example:
You can use the --passthroughauth command-line argument to log in to a vCenter Server system (vCenter Server version 2.5 Update 2 or later). Using
--passthroughauth passes the credentials of the executing user to the server. If the executing user is known by both the machine from which you access the vCenter Server system and the machine running the vCenter Server system, no additional authentication is required.
SSPI supports a number of protocols. By default, it selects the Negotiate protocol, which indicates that client and server attempt to find a mutually supported protocol. Alternatively, you can use
--passthroughauthpackage to specify another protocol supported by SSPI. Kerberos, the Windows standard for domain-level authentication, is commonly chosen.
If the vCenter Server system is configured to accept only a specific protocol, specifying the protocol to vSphere SDK for Perl commands with --passthroughauthpackage might be required for successful authentication to the server. If you use
--passthroughauth, you do not have to specify authentication information in any other way. For example, to run
connect.pl on the server, you can use the following command at the command line.
The following example connects to a server that has been set up to use SSPI. When you run the command, the system calls vminfo.pl with the
--vmname option. The system does not prompt for a user name and password because the current user is known to the server.
|
|
|
|
|
|
|
Name of a credential store file. Defaults to <HOME>/.vmware/credstore/vicredentials.xml on Linux and <APPDATA>/VMware/credstore/vicredentials.xml on Windows. Commands for setting up the credential store are included in the vSphere SDK for Perl, which is installed with vCLI. The vSphere SDK for Perl Programming Guide explains how to manage the credential store.
|
|
■
|
cp936 (Simplified Chinese)
|
You can use - -encoding to specify the encoding vCLI should map to when it is run on a foreign language system.
|
|
|
|
Use this option with - -passthroughauth to specify a domain-level authentication protocol to be used by Windows. By default, SSPI uses the Negotiate protocol, which means that client and server try to negotiate a protocol that both support.
|
|
■
|
If - -server specifies a vCenter Server system, the user name and password apply to that server. If you can log in to the vCenter Server system, you need no additional authentication to run commands on the ESXi hosts that server manages.
|
■
|
If - -server specifies an ESXi host, the user name and password apply to that server.
|
|
|
|
|
|
|
|
|
|
|
If - -server points to a vCenter Server system, you can also specify the --psc option to log in to the vCenter Server system with vCenter Single Sign-On.
|
|
|
|
|
|
|
|
|
|
■
|
If - -server specifies a vCenter Server system, the user name and password apply to that server. If you can log in to the vCenter Server system, you need no additional authentication to run commands on the ESXi hosts that server manages.
|
■
|
If - -server specifies an ESXi system, the user name and password apply to that system.
|
|
|
Note: This option is not supported for each command. If supported, the option is included when you run <cmd> --help.
|