Quick Bites:

This article provides an overview of the VMware vSphere Command-Line Interface (VCLI) and PowerCLI tools and introduces the new Distributed Command-Line Interface (DCLI). It explains the purpose of each tool, the differences between them and provides examples of how to use them in order to manage VMware vSphere environments. The article also outlines the benefits of using these tools and provides resources for learning more about them.

Introduction

Scripting in IT automation still raises concerns because it can be slow, time-consuming, and difficult to maintain. Nobody knows what happened or who wrote the scripts when something goes wrong. Furthermore, keeping documentation up to date is difficult.

Protect Your Data with BDRSuite

Cost-Effective Backup Solution for VMs, Servers, Endpoints, Cloud VMs & SaaS applications. Supports On-Premise, Remote, Hybrid and Cloud Backup, including Disaster Recovery, Ransomware Defense & more!

On the other hand, we have to admit that there are major advantages of automation that include:

  • Easy to learn and use
  • Minimum programming knowledge or experience required
  • Allow complex tasks to be performed in relatively few steps
  • Allow editing with a variety of text editors
  • Allow the addition of dynamic and interactive activities to web pages
  • Faster Editing & Execution

Scripting languages are becoming more popular due to the need to automate our day-to-day tasks. Every VMware administrator must automate basic tasks in order to save time. Managing Hyper-V and vSphere with Command-Line Interfaces is essential.

vSphere supports several command‐line interfaces for managing your virtual infrastructure including a set of ESXi Shell commands, PowerCLI commands, and DCLI commands for management of vCenter services. You can run such commands locally from an administration server or through custom scripts.

Download Banner

Table of Contents

  1. What is vSphere CLI?
  2. What is VMware Datacenter CLI?
  3. Running DCLI Commands on the vCenter Server Appliance
  4. Using DCLI with a Credential Store File
  5. DCLI History File
  6. Running DCLI Commands from a Windows Machine
  7. Conclusion

What is vSphere CLI?

vSphere command-line interfaces allow you to administer your VMware virtual environment. It also lets you automate common tasks that you perform to deploy and support your virtual datacenter such as configuring and managing storage for the ESXi hosts and setting up networking for virtual machines.

Below is an overview of vSphere Command-Line Interfaces from the VMware website:

vSphere Command-Line

ESXCLI commands: Manage many aspects of an ESXi host. You can run ESXCLI commands remotely or in the ESXi Shell. You can also run ESXCLI commands from the vSphere PowerCLI prompt by using the Get-EsxCli cmdlet.

vCLI package: Install the vCLI package on the server of your choice.

  • ESXi Shell: Run ESXCLI commands in the local ESXi shell to manage that host
  • Vicfg: Allow users to manage hosts remotely. Install the vCLI package on a Windows or Linux system or deploy a vMA virtual machine, and target the ESXi system that you want to manipulate

VMware PowerCLI: VMware vSphere PowerCLI provides a Windows PowerShell interface to the vSphere API. vSphere PowerCLI includes PowerShell cmdlets for administering vSphere components. It also includes many cmdlets and a set of sample scripts for management and automation. More information about PowerCLI here: Managing vSphere using VMware PowerCL

Get started with vSphere PowerCLI here

What is VMware Datacenter CLI?

VMware DCLI means VMware Datacenter Command-Line Interfaces, which is used to manage VMware vCenter. DCLI is a CLI client, a DCLI command talks to a VMware API endpoint to locate relevant information and then executes the command and displays the result to the user.

You can run DCLI commands as follows:

vCenter Server Appliance. Run DCLI commands from the vCenter Server Appliance shell.

vCenter Server Windows command prompt. Install vCenter Server on a supported Windows system and run DCLI commands from the command prompt.

Scripts. Use scripts that include DCLI commands and run the scripts as vCLI scripts from the vCenter Server Windows command prompt or from the vCenter Server Appliance shell.

Thanks to VMware DCLI, you can retrieve information about your vCenter infrastructure (Network, storage, VMs, …) and manage VMware resources (create, delete, …) as you can perform using PowerCLI.

Running DCLI Commands on the vCenter Server Appliance

The first thing to perform is to connect to your vCenter server using the SSH protocol. On a Windows machine, open Putty and then type the root credentials. One thing to notice is the syntax.

Unlike other scripting languages that use a “-” in front of each parameter, VMware DCLI will use ‘+’ instead of ‘-‘.

To start a DCLI session, use the following command:

Command> dcli +interactive

Interactive

In this example, the interactive shell uses the dcli> prompt which is the default but you can customize the prompt:

Command> dcli +interactive +prompt VMwareDCLI

prompt VMwareDCLI

Thanks to the interactive mode, you can autocomplete your command. Type the command and then press the spacebar or TAB, to display the available options:

VMwareDCLI

If you need more information about a command, use the –help parameter:

VMwareDCLI

I can easily retrieve information about a specific Virtual Machine. First, I can use the ‘list’ command:

VMwareDCLI> vCenter vm list –names XXXXX

This command returns some basic information such as:

  • VM ID
  • VM Name
  • Power State
  • CPU Count
  • Memory Size

The VM ID is important and can be used with the ‘get’ command:

VMwareDCLI> vCenter vm get –vm YYYYYYY

VMwareDCLI

Using DCLI with a Credential Store File

To avoid typing the username and password each time you run a DCLI command, you can add the current user and the associated password to a credential store file by using the credstore-add option on the command line.

In the following example, I can list the current credential store file using:

Command> dcli +credstore-list

VMwareDCLI

Now, let’s run the ‘credstore-add’ command from a Windows machine to add a new credential store entry.

VMwareDCLI

dcli>com vmware cis tagging tag list +credstore-add +username user1

VMwareDCLI

DCLI History File

DCLI maintains a history file for each DCLI client that runs in interactive mode, which is located in the following directory:

%Appdata%\Roaming\VMware\vapi

VMwareDCLI

The file stores information on a per‐user basis and not on a per‐client basis.

Running DCLI Commands from a Windows Machine

The first thing to do is to install the vSphere CLI package. So download the package from the VMware website:

VMwareDCLI

As you can notice, the package was released in 2018. You can find and download the other package versions at:
https://customerconnect.vmware.com/downloads/get-download?downloadGroup=VS-CLI-670

You must install Python and PyPI: https://pypi.org/project/dcli/ to install DCLI. PyPI is the official 3rd party public repository for Python. PyPI will download and install DCLI onto your local system:

VMwareDCLI

Let’s confirm if Python and PIP are installed:

VMwareDCLI

Then you can run the installation process using the following command:

> pip install dcli

VMwareDCLI

You can still work with DCLI using the vSphere CLI package, but using this way, DCLI will be released on a more regular cadence. So you should use ‘pip’ to work with the latest version.

In my current lab, I will use the vSphere CLI package. First, use the following command to connect to your vCenter server:

> dcli.exe +server https://vCenter/api +interactive +prompt dcli> +skip-server-verification

VMwareDCLI

Below are some basic examples.

  1. List the Virtual Machines in a specific Power State:
  2. VMwareDCLI

  3. Retrieve CPU information for a specific VM:
  4. VMwareDCLI

  5. Show the system time:
  6. VMwareDCLI

Here is the list of DCLI Commands:

  • cis session
  • cis tagging tag
  • cis tagging tagassociation
  • cis tagging category
  • cis data legacy resourcemodel
  • content locallibrary
  • content configuration
  • content library
  • content type
  • content subscribedlibrary
  • content library subscribeditem
  • content library item
  • content library item storage
  • content library item downloadsession
  • content library item file
  • content library item updatesession
  • content library item updatesession file
  • content library item downloadsession file
  • appliance monitoring
  • appliance vmon service
  • appliance networking interfaces
  • appliance networking dns servers
  • appliance networking dns hostname
  • appliance networking dns domains
  • appliance health load
  • appliance health system
  • appliance health storage
  • appliance health softwarepackages
  • appliance health mem
  • appliance health swap
  • appliance health databasestorage
  • appliance health applmgmt
  • appliance access shell
  • appliance access ssh
  • appliance access consolecli
  • appliance access dcui
  • appliance techpreview shutdown
  • appliance techpreview timesync
  • appliance techpreview ntp
  • appliance techpreview services
  • appliance techpreview networking routes
  • appliance techpreview networking ipv6
  • appliance techpreview networking ipv4
  • appliance techpreview networking proxy
  • appliance techpreview networking firewall addr inbound
  • appliance techpreview services status
  • appliance techpreview localaccounts user
  • appliance techpreview monitoring snmp
  • appliance techpreview ntp server
  • appliance techpreview system update
  • appliance recovery backup
  • appliance recovery restore
  • appliance recovery backup parts
  • appliance recovery backup job
  • appliance recovery restore job
  • appliance system storage
  • appliance system uptime
  • appliance system version
  • appliance system time
  • vcenter datacenter
  • vcenter network
  • vcenter folder
  • vcenter host
  • vcenter vm
  • vcenter datastore
  • vcenter resourcepool
  • vcenter cluster
  • vcenter iso image
  • vcenter inventory network
  • vcenter inventory datastore
  • vcenter vm hardware
  • vcenter vm power
  • vcenter vm hardware boot
  • vcenter vm hardware serial
  • vcenter vm hardware ethernet
  • vcenter vm hardware cdrom
  • vcenter vm hardware disk
  • vcenter vm hardware floppy
  • vcenter vm hardware memory
  • vcenter vm hardware parallel
  • vcenter vm hardware cpu
  • vcenter vm hardware adapter sata
  • vcenter vm hardware adapter scsi
  • vcenter vm hardware boot device
  • vcenter ovf exportflag
  • vcenter ovf libraryitem
  • vcenter ovf importflag

You can get more information about these commands here:
https://developer.vmware.com/docs/4676/data-center-cli-reference/doc/intro.html

Conclusion

The advantage of DCLI over PowerCLI is, it is very simple to use. But in DCLI, you must learn a new syntax, also the scripting language is a bit more complex. So, I advise you to use PowerCLI if you are a VMware administrator having familiarity with PowerShell.

If you don’t use PowerShell, then you can try VMware DCLI to suit your needs.

Read more on PowerCLI:
Managing vSphere using VMware PowerCLI
What’s New in PowerCLI 12
Build your Own Tailored PowerCLI Commands

If you’re an IT administrator seeking to ensure the secure backup of your VMware workloads, consider trying out BDRSuite. Our backup solution is known for its robustness, comprehensiveness, and cost-effectiveness. You can start by downloading a free trial of BDRSuite here: Download BDRSuite. Additionally, if you’re interested in Hyper-V backup, you can find more information here: Hyper-V Backup.

Follow our Twitter and Facebook feeds for new releases, updates, insightful posts and more.

Rate this post