Command Line

Finding the correct esxcli command

The ESXi command esxcli has many namespaces and options to choose from. It may sometimes be hard to find what the exact command is to perform a task. You can of course use a search engine to find what you need. But with this practical tip you can also find what you need with the esxcli command itself.

First let's have a look at the command itself. When you execute the command without any parameters it will show the possible options and namespaces.

Set timeout to 0 for vSphere Client with a script

The vSphere Client and vSphere Web Client in the vCenter Appliance both have a timeout of 120 minutes. NSX-T has a timeout of 30 minutes. When I am teaching VMware classes the client always has just timed out when I want to demonstrate something to my students and I then have to re-login. So therefor I always configure the timeout to 0 (no timeout) at the start of each class. It is documented here how to do that:

How to fix a vCenter Appliance No-Networking problem

This problem might occur with your vCenter Server Appliance. But it could also happen with other Linux-servers. It might happen when you move the virtual machine, clone it, restore it, recover it from replication or perform any other action where the MAC Address of the virtual machine changes. This is what you would see on the console of the virtual appliance:

vCenter Appliance No Networking error

Basic commands for the VI editor

When you need to edit files on an ESXi host directly or on a Linux-host, such as the vCenter appliance, then it is a useful skill to be able to use the VI-editor. In this article I describe the absolute basics you need to know.

The easiest way to open a file with the VI-editor is to start the program with the filename of the file to edit as a parameter. Such as this:

vi /etc/udev/rules.d/70-persistent-net-rules

When did my ESXi host boot?

In the vSphere Client and vSphere Web Client you can find how many days your host has been running. But what happened before that period? How often did your host boot in the past? This information is stored in the file /var/log/vmksummary.log on your ESXi-host. The file is updated  hourly with information how long your host has been up and how many virtual machines are running at that moment.

How to crash your server to test HA

There are several ways to test if HA is working. You can unplug the power of your server or perform a reset of the machine and a fail over will take place. In training classes and for demo's it's nicer if you can actually have the server to crash and show a Purple Screen of Death (PSOD).

vsish command

This is the command to execute:

vsish -e set /reliability/crashMe/Panic 1

Import and Export Virtual Machines from the command line with VMware's OVF Tool

Importing Virual Machines (also called deploying OVF templates) or exporting them into the OVF format can be done with the vSphere Client, vSphere Web Client or from the vCloud Director management portal. But did you know you can also perform these actions from the command line? There is a utility available from VMware that runs on Linux and Windows that allows you to perform these actions from the command line, and thus can also be used in scripts.

Shrink a VMware Workstation disk with VMware Tools command line utility in Windows

You can shrink a disk from inside a virtual machine running Windows with a command line utility named VMwareToolboxCmd.exe. The disk must not be a pre-allocated disk but should grow dynamically. 

Shrinking a disk can also be done from the Control Panel VMware tools entry, but when that is not available you can also do this from the command line. The utility is located in the folder C:\Program Files\VMware\VMware Tools.

Follow us on LinkedIn

  

   

   

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer