In one of my previous blog posts, I showed you how to build your own VCF 4.0.1 home lab with VLC. I would like to share my start and stop scripts for a VCF home lab with the VMware community. Starting and stopping my VCF home lab was always a manual task and took a lot of time. So I started with automating these manual tasks with powerCLI and used it since then.

VCF start and stop scripts

Starting procedure of my VCF home lab:

  • Starting all the 4 or more nested ESXI hosts.
  • Wait for the ESXI hosts to become available.
  • Log on per ESXI host and start the VCF components.

Stopping procedure of my VCF home lab:

  • Stop all the VCF components.
  • Power off all vCLS VMs (if enabled in settings).
  • Verify if all the VCF components are powered off.
  • Put all nested ESXI hosts in maintenance mode.
  • Power off all nested ESXI hosts.

Settings Params

The settings need to be adjusted to your VCF home lab. In the settings part of the powershell script, we can configure the physical ESXI host or vCenter server that manage the nested VCF lab. Credentials for the physical ESXI host or vCenter server will be asked during the execution of the script (see screenshots).

The VM name and the IP addresses of the nested ESXI hosts need to be added in the $nHosts array as shown below. Also, the credentials of the nested ESXI hosts need to be added as well in the settings Nested ESXI hosts settings. In the VCF components settings, we can define the VM names of the components like vCenter, NSX-T, SDDC-Manager, Edge nodes and vRSLCM components.

vSphere 7.0 update has been included in the VCF 4.1 release. Because of that, I have added an additional variable named $vCLS. This will make sure that the vCLS agent VMs will be powered off during the execution off the Stop-VLCLab.ps1 script. You only have enable or disable it with $true or $false.

Log files will be created for the start and stop tasks. Log files will be stored in the same directory where the powershell script is located. You can also enable $verboseLogging with $true or $false to output every log action.

Example settings

##Settings
$begintime = Get-Date
$verboseLogging = $false  #$true or $false
##Physical ESXI host or vCenter server settings
$pHost = "esxi-1.lab.vkb.lan"
$pCredentials = Get-Credential -Message "Enter the credentials of the physical ESXI host or vCenter server."
##Nested ESXI hosts
$nHosts = @(
        [PSCustomObject]@{Name = "vcf-esxi-1"; IP = "192.168.11.27"}
        [PSCustomObject]@{Name = "vcf-esxi-2"; IP = "192.168.11.28"}
        [PSCustomObject]@{Name = "vcf-esxi-3"; IP = "192.168.11.29"}
        [PSCustomObject]@{Name = "vcf-esxi-4"; IP = "192.168.11.30"}
        [PSCustomObject]@{Name = "vcf-esxi-5"; IP = "192.168.11.31"}
        [PSCustomObject]@{Name = "vcf-esxi-6"; IP = "192.168.11.32"}
)
$nUser = "root"
$nPassword = "VMware1!VMware1!"
$nCredentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $nUser, (ConvertTo-SecureString -String $nPassword -AsPlainText -Force)
##VCF Components (VM names of the components)
$VCF_Components = "vcenter-mgmt", "nsx-mgmt-1", "sddc-manager", "edge01-mgmt", "edge02-mgmt"

Download Start and Stop scripts

The VCF start and stop scripts can be downloaded from my Github page.

How to use

  1. Match the settings with your VCF home lab.
  2. Select the script (right mouse click) and click on Run with powershell
  3. Fill in the credentials of your physical ESXI host or vCenter server that manage the nested VCF lab.
  4. Wait for a few minutes until the script is done.

Note: Do not run the script from a Visual studio code or Powershell ISA console, this could cause issues with the logging functionality in the script.

Screenshots

VCF start and stop scripts
Start and stop scripts vcf

Final words

I hope that this script will be useful for your VCF home lab. In case you have any questions or if you need any help with the script, please do not hesitate to contact me.