Create and Use a
Session File
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.
- Navigate to the directory where the script is located.The following examples show possible locations of the script.Operating SystemCommandWindowscd C:\Program Files\VMware\VMware vSphere CLI\Perl\apps\sessionLinuxcd /usr/share/lib/vmware-vcli/apps/session
- Runsave_session.You can use thesave_session.plscript or the--savesessionfileoption 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 SystemCommandWindowssave_session.pl --savesessionfile C:\Temp\my_session --server my_server --username <username> --password <password>Linuxsave_session --savesessionfile /tmp/vimsession --server <servername_or_address> --username <username> --password <password>If you specify a server, but no user name or password, the script prompts you.
- When you run vCLI commands, pass in the session file using the--sessionfileoption.<command> --sessionfile <sessionfile_location> <command_options>The following examples show the correct syntax for each OS.Operating SystemCommandWindowsesxcli --sessionfile C:\Temp\my_session network ip interface listvicfg-mpath.pl --sessionfile C:\Temp\my_session --listLinuxesxcli --sessionfile /tmp/vimsession network ip interface listvicfg-mpath --sessionfile /tmp/vimsession --list