Updating a Single ESXi Host on an Intel NUC Using PowerCLI

Last year, I purchased an Intel NUC to host a few small virtual machines at home. Currently, I’m running a Unify management server, a VPN server, and a Pihole server on it. The Intel NUC has proven to be the ideal hardware for my home setup — compact, quiet and reliable. Although it’s not officially supported and lacks a built-in network driver, that hasn’t been a problem for me. Fortunately, the Fling program offers a “Community Network Driver for ESXi,” which has been a great solution.

ESXi with Community Network Driver

Inspired by virten.net , I’ve used a bootable USB drive to do the initial installation of the custom ESXi with the community driver. This was a useful explanation how to run ESXi on an Intel NUC.

However, like many others, I don’t like manual work. When VMware vSphere ESXi 8.0 U3 was released, I started thinking, if there might be a quicker, more efficient way to update a single host with minimal manual intervention? Keeping in mind I need to add the community drivers every time. 

The script

Before running the script, make sure you have the following:

Connect to the Single host

Before we can connect to the host, we need the credentials.

$Credentials = Get-Credential -Message "Please enter your credentials to log on to vCenter"
Connect-VIServer -Server $SingleHost -Credential $Credentials | Out-Null
Modify the Timeout Setting for Web Tasks

I’ve got a timeout when installing the update. To avoid this, set the timeout setting for the current session to 30 minutes. Store the initial timeout value in a variable, after the upgrade we can set it back to original.

$initialTimeout = (Get-PowerCLIConfiguration -Scope Session).WebOperationTimeoutSeconds
Set-PowerCLIConfiguration -Scope Session -WebOperationTimeoutSeconds 1800 -Confirm:$false | Out-Null
Power off the running VM’s

During the upgrade, the host cannot have any running VMs. In a multi-node cluster, you can migrate all running VMs to other hosts. However, on a single host, you will need to shut them down.

$RunningVMs = get-vm | Where-Object PowerState -like "PoweredOn"
$RunningVMs | Stop-VM -Confirm:$false | Out-Null
Enter Maintenance Mode

Before upgrading the ESXi host, you will need to place the host in maintenance.

Get-VMHost $SingleHost | Set-VMHost -State Maintenance | Out-Null
Create update bundle with community network drivers

Add an ESXi software depot or offline depot ZIP file to the current PowerCLI session. Do the same fot the community bundle.

Add-EsxSoftwareDepot $UpgradeBundle
Add-EsxSoftwareDepot $NetBundle

Create an image profile by cloning it from the upgrade bundle. Give it a new name and vendor.

New-EsxImageProfile -CloneProfile "$($build)-standard" -name "$($build)-standard-NUC" -Vendor "MerlevedeN"

Add the Net-Community package

Add-EsxSoftwarePackage -ImageProfile "$($build)-standard-NUC" -SoftwarePackage "net-community"

Export the new image

Export-ESXImageProfile -ImageProfile "$($build)-standard-NUC" -ExportToBundle -filepath "$($build)-standard-NUC.zip" -Force
Upload the new image
$datastore = Get-Datastore
Copy-DatastoreItem -Item "$($build)-standard-NUC.zip" -Destination $datastore.DatastoreBrowserPath
Run esxcli with powercli

Use the Get-EsxCli cmdlet to create the object that you can run commands against. Make sure to add the -V2 parameter to use new interface.

$esxcli = get-esxcli -VMHost $singlehost -v2

Define the depot and profile.

$InstArgs = $esxcli.software.profile.install.createargs()
$InstArgs.depot = $datastore.ExtensionData.Info.url  + "/"+ "$($build)-standard-NUC.zip"
$InstArgs.profile = "$($build)-standard-NUC"

Install the update bundle

$esxcli.software.profile.install.Invoke($InstArgs)
After the installation

After the upgrade process is completed, the timeout settings are restored to default and the host needs a reboot to activate the new ESXi version.

Get-VMHost $SingleHost | Restart-VMHost -Confirm:$false

Just to be sure everything is fine, I added a sleep of 5 minutes.

Verify the Upgrade
$Version = Get-VMHost $SingleHost | Select-Object Version, Build, Name
Write-host "Host information after upgrade: " -ForegroundColor Green
Write-Host "Version: " -ForegroundColor Blue -NoNewline
Write-host $Version.Version
Write-Host "Build: " -ForegroundColor Blue -NoNewline
Write-host $Version.Build
Exit maintenance mode
Get-VMHost $SingleHost | Set-VMHost -State Connected | Out-Null
Power on the VM’s
$RunningVMs | Start-VM -Confirm:$false | Out-Null

Congrats, you’re host is up-to-date!