ESXi-Shutdown Single Virtual Machine

To shutdown single virtual machine, you need to get the Vmid:

Using the following command:
vim-cmd vmscv/getallvms
will display the follow:
'Vmid' 'Name' 'File' 'Guest OS' 'Version' 'Annotation'

However, it not reader friendly and any annotation scroll down the screen as seen below:

To get just ‘Vmid’ & ‘Name’ use the following:

vim-cmd vmsvc/getallvms | sed '1d' | grep vmx | awk '{if ($1 > 0) print $1"^"$2}'
1^win2012SQL
10^kubenode1
11^kubenode2
13^win2016-ADROOT
14^win10
15^win2016-AMI
16^kubemaster
17^kali-linux-2022.1-vmware-amd64
18^burwin10-esx
19^win2016-SNOW
2^QNAP-ubuntu
20^GNS3
21^FreeIPA
22^Proxmox
23^kube-desktop_template
24^kuber_template
25^esx_maas_vm
26^udesk
29^kube-dev1-master
3^win2012
30^OpenStack_All-in-ine
33^ansible-awx
34^minikube_master
35^ros-master
36^wazuh
37^pfsense-esxi
38^apache
4^ubuntu
5^QNAP-win2012
6^GNS3_old
7^vSphere

Now we can shutdown single VM

[root@ESXi:~] vim-cmd vmsvc/power.shutdown 16
[root@ESXi:~]

Notice nothing is returned, so to verify:

[root@ESXi:~] vim-cmd vmsvc/power.getstate 16
Retrieved runtime info
Powered off

Leave a Reply