You can use vifs to interact with the remote ESXi or vCenter Server system in a variety of ways.

Specify one of the connection options listed in Connection Options for vCLI Host Management Commands in place of <conn_options>.

Note

The examples illustrate use on a Linux system. You must use double quotes instead of single quotes when on a Windows system.

List all data centers on a vCenter Server system with --listdc, using --server to point to the vCenter Server system.

vifs --server <my_vc>--username administrator --password <pswd> --listdc

List all datastores on a vCenter Server system with --listds.

vifs --server <my_vc> --username administrator --password <pswd> --dc kw-dev --listds

List all datastores on an ESXi host with --listds.

vifs --server <my_ESXi> --username root --password <pswd> --listds

The command lists the names of all datastores on the specified server.

You can use each name that has been returned to refer to datastore paths by using square bracket notation.

'[my_datastore] dir/subdir/file'

List the content of a directory in a datastore.

vifs --server <my_ESXi> --username root --password <pswd>--dir '[Storage1]'
vifs --server <my_ESXi> --username root --password <pswd> --dir '[Storage1] WindowsXP'

The command lists the directory content. In this example, the command lists the contents of a virtual machine directory.

Content Listing
_________________
vmware-37.log
vmware-38.log
...
vmware.log
...
winxpPro-sp2.vmdk
winxpPro-sp2.vmx
winxpPro-sp2.vmxf
...

List the contents of one of the datastores.

vifs <conn_options> --dir '[osdc-cx700-02]'

The command lists the complete contents of the datastore.

Create a new directory in a datastore with --mkdir <remote_dir>.

vifs --server <my_ESXi> --username root --password <pswd> --mkdir '[Storage1] test'

Remove a directory with --rmdir <remote_dir>.

vifs --server <my_ESXi> --username root --password <pswd> --rmdir '[Storage1] test'

Forcibly remove a directory with --rmdir --force <remote_dir>.

vifs --server <my_ESXi> --username root --password <pswd> --rmdir '[Storage1] test2' --force

Update a file on the remote server with --put <local_path> <remote_path>.

vifs --server <my_ESXi> --username root --password <pswd>
--put /tmp/testfile '[Storage1] test/testfile'

Retrieve a file from the remote server with --get <remote_path> <local_path>|<local_dir>. The command overwrites the local file if it exists. If you do not specify a file name, the file name of the remote file is used.

vifs --server <my_ESXi> --username root --password <pswd> --get '[Storage1] test/testfile' /tmp/tfile
vifs --server <my_ESXi> --username root --password <pswd> --get '[Storage1] test/testfile' /tmp

Delete a file on the remote server with -rm <remote_path>.

vifs --server <my_ESXi> --username root --password <pswd> --rm '[Storage1] test2/testfile'

Forcibly remove a file on the remote server with --rm <remote_path> --force.

vifs --server <my_ESXi> --username root --password <pswd> --rm '[Storage1] test2/testfile2' --force

Move a file from one location on the remote server to another location with --move <remote_source_path> <remote_target_path>. If you specify a file name, the file is moved and renamed at the same time.

vifs --server <my_ESXi> --username root --password <pswd> --move '[Storage1] test/tfile' '[Storage1] newfile'

If the target file already exists on the remote server, the command fails unless you use --force.

vifs --server <my_ESXi> --username root --password <pswd> --move '[Storage1] test/tfile2' '[Storage1] test2/tfile' --force

Create a copy of a file on the remote server at a different location on the remote server.

vifs --server <my_ESXi> --username root --password <pswd> --copy '[Storage1] test/tfile' '[Storage1] test/tfile2'

If the target file already exists on the remote server, the command fails unless you use --force.

vifs --server <my_ESXi> --username root --password <pswd> --copy '[Storage1] test/tfile' '[Storage1] test/tfile2' --force

The following example scenario illustrates other uses of vifs.

1

Create a directory in the datastore.

vifs <conn_options> --mkdir '[osdc-cx700-03] vcli_test'
Note

You must specify the precise path. There is no concept of a relative path.

2

Place a file that is on the system from which you are running the commands into the newly created directory.

vifs <conn_options> --put /tmp/test_doc '[osdc-cx700-03] vcli_test/test_doc'
3

Move a file into a virtual machine directory.

vifs <conn_options> - -move '[osdc-cx700-03] vcli_test/test_doc'
   '[osdc-cx700-03] winxpPro-sp2/test_doc

A message indicates success or failure.

4

Retrieve one of the files from the remote ESXi system.

vifs <conn_options> --get '[osdc-cx700-03] winxpPro-sp2/vmware.log' ~user1/vmware.log

Retrieves a log file for analysis.

5

Clean up by removing the file and directory you created earlier.

vifs <conn_options> --rm '[osdc-cx700-03] vcli_test/test_doc'
vifs <conn_options> --rmdir '[osdc-cx700-03] vcli_test'