Find aggregate allocated VM CPU and Memory per host basis

Here’s a quick and dirty one-liner to find the total allocated CPU & Memory per ESXi host basis. This is useful when you want to get a quickly get your over-commitment ratios.

$TotalMem=0; Get-VMHost myESXiHost1 | Get-VM | ?{$_.PowerState -match 'PoweredOn'} | %{$TotalMem=$TotalMem+$_.MemoryGB};Write-Host $TotalMem
$TotalCPU=0; Get-VMHost myESXiHost2 | Get-VM | ?{$_.PowerState -match 'PoweredOn'} | %{$TotalCPU = $TotalCPU+$_.numCPU};Write-Host $TotalCPU

vSphere Snapshot Basics – Part 2

More about Snapshots

Snapshots are not backups, but backup software will leverage snapshots to take backups of the VM.

  • When you take snapshots the delta disks can potentially grow to the size of the original disk
  • When you take snapshots be careful because you can easily run out of storage space on the datastore

Snapshot Best Practices

If you plan to take snapshots

  • Do not over commit the datastore capacity
  • In fact you should be under commit by up to 30%
  • Do not create more than 1 snapshot
  • Do not keep snapshots for more that 1 day, in exceptional cases on production VMs (powered VMs) you may keep it up to 2 days

Difference between Clone and Snapshot

Clone is another copy of the virtual machine, where as a snapshot is a capture of point time state of the virtual machine. If you delete the virtual machine, the snapshot will also be deleted along with the it, however the clone will remain intact because its a separate copy.

vSphere Snapshot Basics – Part 1

What is a Snapshot?

  • It is a point in time state of the virtual machine
  • When you take a snapshot a delta disk gets created.
  • If you create another snasphot another delta disk will be created
  • The delta disk is mounted as ReadWrite (RW) whereas the original disk is mounted as ReadOnly (RO)
  • This delta disk is thin priovisioned disk, and grows in chunks of 16MB
  • After creation of Snapshot all disk writes within the VM go to the Snapshot-disk (delta disk) and not to the original disk (flat disk)

In vSphere, snapshots are based on “COW“

COW ==> Copy on Write Snapshots

In COW, all new writes always go to the delta disk.

Enumerating GuestId supported by VMware ESXi

Today when googling for various GuestId supported by VMware ESXi, I found a cool way that someone posted to “serverfault”. Here is a piece of PowerCLI code to do exactly that:


For reference, here is the original link where I found this:


Restore ESXi Connectivity when “Management Network” is deleted

Today one of my friends accidentally deleted the “Management Network” Port Group on a ESXi. Here’s what I did to restore the network connectivity to the ESXi host:


  1. Login to the DCUI of the ESXi host in question
  2. In the DCUI go to “Troubleshooting Options” and “Enable ESXi Shell”
  3. Press “Alt + F1” for logging in via the ESXi Shell
  4. After Logging in execute the following commands to restore the connectivity.

In our case the “Management Network” Port Group, was deleted so first we have to recreate the “Management Network” Port Group:

esxcfg-vswitch -A "Management Network" vSwitch0

After the “Management Network” is recreated, add a VMKernel Interface to the just created “Management Network” Port Group:

esxcfg-vmknic -a -i 10.20.30.x -n "Management Network"

Logout from the shell. Go back to DCUI [Alt + F2]. Logout from DCUI and Relogin and test “Management Network” connectivity.

That’s all.