Hello! Long time, no scripting! I’ve been blowing through VCF, deploying, redeploying, and built some scripts to help me with this. Sharing is caring, read on to see what I’ve done…

Host Preparation

This script sets some of the required configuration for VCF:

  • Sets the hostname fqdn to the name supplied in the array. This is needed if the hostname is still localhost from a manual install
  • Sets DNS servers, network domain name & search domains
  • Adds NTP server
  • Enables & starts ssh
  • Enables & starts ntpd
  • Regenerates certificates & reboots

Leave vSAN

Use this script before reinstall of ESXi

This script forces the host to leave the vSAN cluster, and then delete all disk groups. It stops all running VMs and removes from inventory. This is useful in case you have the cloud builder VM on a local datastore with snapshots. After you reinstall ESXi, you can import the VMX file and restore from snapshot.

Wipe Partitions

Use this script if vSAN was not wiped before reinstall of ESXi

This script is needed if you’ve reinstalled ESXi without properly leaving a vSAN cluster or deleting the vSAN disk group from the ESXi host and vSAN partitions are left on the disks.

You may need to edit the commands to meet your needs for the disks. The servers this was written for has the OS on M.2 drives, NVMe cache disks, and SAS capacity disks.

Where’s the script?

I created a github repo to store the scripts so others can fork, contribute, do whatever you need.

https://github.com/ThepHuck/VCF_Preparation/tree/main