You can create a session file with the save_session script.

The save_session script is in the /apps/session directory of the vSphere SDK for Perl, which is included in the vCLI package. You can use the session file, which does not reveal password information, when you run vCLI commands. If the session file is not used for 30 minutes, it expires.

If you use a session file, other connection options are ignored.

1

Navigate to the directory where the script is located.

The following examples show possible locations of the script.

Operating System

Command

Windows

cd C:\Program Files\VMware\VMware vSphere CLI\Perl\apps\session

Linux

cd /usr/share/lib/vmware-vcli/apps/session

2

Run save_session.

You can use the save_session.pl script or the --savesessionfile option to the vCLI command. You must specify the server which to connect to and the name of a session file in which the script saves an authentication cookie.

save_session --savesessionfile <location> --server <server>

The following examples show the correct syntax for each OS.

Operating System

Command

Windows

save_session.pl --savesessionfile C:\Temp\my_session --server my_server --username <username> --password <password>

Linux

save_session --savesessionfile /tmp/vimsession --server <servername_or_address> --username <username> --password <password>

Note

If you specify a server, but no user name or password, the script prompts you.

3

When you run vCLI commands, pass in the session file using the --sessionfile option.

<command> --sessionfile <sessionfile_location> <command_options>

The following examples show the correct syntax for each OS.

Operating System

Command

Windows

esxcli --sessionfile C:\Temp\my_session network ip interface list

vicfg-mpath.pl --sessionfile C:\Temp\my_session --list

Linux

esxcli --sessionfile /tmp/vimsession network ip interface list

vicfg-mpath --sessionfile /tmp/vimsession --list