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.


Some KB articles about Snapshots

  • KB#1002929: Creating snapshots in a different location than default virtual machine directory
  • KB#1004343: Determining if a virtual machine is using snapshots
  • KB#1006392: Unable to use Snapshots or perform a backup on virtual machines configured with bus-sharing
  • KB#1007849: Consolidating snapshots
  • KB#1012384: Creating a snapshot for an ESX/ESXi virtual machine fails with the error: File is larger than maximum file size supported
  • KB#1015180:Understanding virtual machine snapshots in VMware ESXi and ESX
  • KB#1025279: Best practices for virtual machine snapshots in the VMware environment
  • KB#1007969: Resolving the CID mismatch error: The parent virtual disk has been modified since the child was created
  • KB#1018457: Attaching an RDM with snapshots to a virtual machine
  • KB#1026353: Recreating a missing virtual disk (VMDK) descriptor file for delta disks
  • KB#1027429: Deleting a snapshot during a virtual machine restore process using VMware Virtual Disk Development Kit fails with the error: The parent disk has been modified since the child disk has been created

LUN Runtime Name


Most vSphere Administrators need to inspect the LUN runtime names discovered by the ESXi hosts. What usually gets overlooked is that runtimes name across different hosts could be different. Hence I like to look at all the runtime names discovered across all hosts for that ‘said’ LUN. Here is an oneliner which does the same, pass the CanonicalName (NaaID) and it will tell you the RuntimeName:

function Get-DatastoreRuntimeName() {
    param (
        [string]$CanonicalName = $(Read-Host -prompt "Enter a CanonicalName")

    Get-VMHost `
        | Get-VMHostStorage `
        | Select-Object -ExpandProperty ScsiLun `
        | ?{$_.LunType -like "disk"} `
        | Select-Object VMHost,CanonicalName,RuntimeName,@{Name="CapacityGB";Expression={[int]$_.CapacityGB}} `
        | ?{$_.CanonicalName -like $CanonicalName}

What I usually do is find the NaaID for a Datastore and then use the NaaID to query the RuntimeName. Yes that’s a 2 step process. There might be an better way, but haven’t tried to explore it, since this gets my job done. 😉

vSphere Datastore Report

I needed to generate a Datastore report. All the information I was interested in was available in via the Get-Datastore cmdlet, however it was nested deep. Hence churned up a quicky PowerCLI oneliner:

Get-Datastore `
    | Select-Object -ExpandProperty ExtensionData `
    | Select-Object `
        @{Name="Name"; Expression={$_.Name}},`
        @{Name="CanonicalName"; Expression={$_.Info.Vmfs.Extent.DiskName}},`
        @{Name="CapacityGB"; Expression={[int]($_.Summary.Capacity/1GB)}},`
        @{Name="FreeGB"; Expression={[int]($_.Summary.FreeSpace/1GB)}},`
        @{Name="ProvisionedGB";Expression={[int](($_.Summary.Capacity - $_.Summary.FreeSpace + $_.Summary.Uncommitted)/1GB)}},`
        @{Name="Moref"; Expression={$_.MoRef}} `
    | ft

In case you are interested in the details of a specific datastore, you can filter the output from the previous oneliner, using the Where-Object cmdlet.

Check VMHost VAAI Status

I needed a quick way to generate a report about VAAI status for all hosts in the vCenter Server. Hence wrote a PowerCLI oneliner to get the job done:

Get-VMHost  | %{ 
  Get-AdvancedSetting -Name DataMover.HardwareAcceleratedMove -Entity $_
  Get-AdvancedSetting -Name DataMover.HardwareAcceleratedInit -Entity $_
  Get-AdvancedSetting -Name VMFS3.HardwareAcceleratedLocking  -Entity $_
} | Select-Object `
        @{Name="Name"; Expression={$_.Entity}},`
        @{Name="PropertyName"; Expression={$_.Name}},`
        @{Name="Status"; Expression={ if($_.Value){"Enabled"} else{"Disabled"}}}

In case you are not aware of what VAAI is read about it here at KB#1021976.

Scripted ESXi Installation

I know there are many blog articles out there that deal with this subject. But this is basically for my reference, hence documenting it here.

I wanted to have a an automated way of installing ESXi quickly, as I end with unclean ESXi installs after testing some customer environments or setups. So I decided to leverage vSphere kickstart installation to make the process easy.

My kickstart file looks like the following:

# Following clear all partitions on the local disks
clearpart --alldrives --overwritevmfs
install --firstdisk --overwritevmfs
# Following will create a VMFS on the second local drive
partition esx1:local --ondisk=mpx.vmhba1:C0:T1:L0
network --bootproto=static --device=vmnic0 --addvmportgroup=1 --ip= --netmask= --hostname=esx1.foobirds.local --gateway= --nameserver=
rootpw vmware

# following code gets executed only on firstboot after the install
%firstboot --interpreter=busybox
# Now if your kickstart file is located on a NFS share, the NFS mount
# remains on the freshly installed ESXi, the nfs mount name that remains
# is "remote-install-location"
# Following code removes (stale) nfs mount after install
dsName=`esxcli storage nfs list | awk 'END{print $1}'`
esxcli storage nfs remove -v=${dsName}

If you want to do a scripted  install where kickstart file resides on a NFS share, then:

Boot with the ESXi installer CD and use the following command at the boot prompt after pressing ‘Shift +O’:

instead of:


use the following command line:

mboot.c32 -c boot.cfg ks=nfs://

If you want to create a custom ISO image of ESXi installer along with embedded kickstart file, follow instructions as mentioned in vSphere documention.

Copy your kickstart file to the root of the ESXi installer and recreate the ISO as documented in the vSphere documentation. Once done, to ensure that ESXi install happens as per the specified kickstart file, edit the following:


And then modify the


To read as

kernelopt=runweasel ks=cdrom:/ESX_KS.CFG

Important: One gotcha that you should be aware of is that, although you may have entered the kickstart file name correctly, but still the installer may fail to find the kickstart file. This is a known issue and is documented in this KB#1026373 article along with a work around.

For a detailed information about kickstart file options and commands, read this KB#2004582 article.

That’s it.

PowerCLI oneliner to generate version, build and bios details

Here’s a quick oneliner to generate a nice report about the version, build and bios details on each host.

Get-VMHost | Select-Object -Property Name,Version,Build,@{Name='BIOS Version';Expression={(($_|Select-Object -ExpandProperty ExtensionData).Runtime.HealthSystemRuntime.SystemHealthInfo.NumericSensorInfo | ?{$_.Name -like "*bios*"}).Name.Split(' ')[4]}}

PS: there are no spaces or new lines in the code.