This is sort of a follow-up on VMware ESXi console: viewing all VMs, suspending and waking them up: part 4 which already gave part of the configuration details of all the configured VMs.
Back then, we ended with this:
List the
vmid
values, power status and name of all VMsBack to the listing script
vim-cmd-list-all-VMs.sh
:#!/bin/sh # https://wiert.me/2021/04/29/vmware-esxi-console-viewing-all-vms-suspending-and-waking-them-up-part-4/ vmids=`vim-cmd vmsvc/getallvms | sed -n -E -e "s/^([[:digit:]]+)\s+((\S.+\S)?)\s+(\[\S+\])\s+(.+\.vmx)\s+(\S+)\s+(vmx-[[:digit:]]+)\s*?((\S.+)?)$/\1/p"` for vmid in ${vmids} ; do powerState=`vim-cmd vmsvc/power.getstate ${vmid} | sed '1d'` name=`vim-cmd vmsvc/get.config ${vmid} | sed -n -E -e '/\(vim.vm.ConfigInfo\) \{/,/files = \(vim.vm.FileInfo\) \{/ s/^ +name = "(.*)",.*?/\1/p'` vmPathName=`vim-cmd vmsvc/get.config ${vmid} | sed -n -E -e '/files = \(vim.vm.FileInfo\) \{/,/tools = \(vim.vm.ToolsConfigInfo\) \{/ s/^ +vmPathName = "(.*)",.*?/\1/p'` echo "VM with id ${vmid} has power state ${powerState} (name = ${name}; vmPathName = ${vmPathName})." done
It uses vim-cmd vmsvc/getallvms
, vim-cmd vmsvc/power.getstate
and vim-cmd vmsvc/get.config
with some sed
and a for
loop from dash
to generate a nice list of information.
A long time ago, I already figured out that vim-cmd vmsvc/get.guest #
gives all guest information including network information for a running VM that has either VMware Tools or open-vm-tools running (see VMware ESXi console: viewing all VMs, suspending and waking them up: part 3 for the difference between these two tools).
A full output of a sample VM is below the signature.
There are a few places that have the LAN ipAddress
. For now, I choose to use only the IPv4 main address from ipAddress
, which is in between (vim.vm.GuestInfo) {
and net = (vim.vm.GuestInfo.NicInfo) [
.
I modified the above script to become this: