Managing vSphere Lifecycle Manager Standalone Hosts with PowerCLI

Starting with vSphere 8.0 and VMware PowerCLI 13.1.0, you can manage vSphere Lifecycle Manager standalone hosts with PowerCLI.

Host-level Functionality in PowerCLI

In PowerCLI 13.1.0 and later, you can use both high-level and low-level cmdlets that bind directly to the ESX REST APIs to manage vSphere Lifecycle Manager hosts.

Starting with VMware PowerCLI 13.1.0, some of the host-level operations you can perform are:
  • Activate vSphere Lifecycle Manager on a standalone host.
  • Retrieve vSphere Lifecycle Manager image profiles:
    • ESXi version
    • Vendor add-ons
    • Firmware/ drivers
    • Components
  • View/ check recommended images.
  • Retrieve a host with a vSphere Lifecycle Manager desired state.
  • Modify the desired state of a vSphere Lifecycle Manager host.
  • Convert a vSphere Update Manager host into a vSphere Lifecycle Manager host.
  • Update the ESXi base image of a standalone host.
  • Add, remove, replace, upgrade, or downgrade a vendor add-on on a standalone host.
  • Add remove, replace, upgrade, or downgrade a vSphere Lifecycle Manager firmware add-on on a standalone host.
  • Check compliance of a standalone ESXi host.
  • Pre-check a host.
  • Stage a host.
  • Apply the desired state on a standalone host, whose current state is different from the desired specification (remediate host).

Sample Scripts for vSphere Lifecycle Manager Host-Level Operations

The following scripts demonstrate how you can use vSphere Lifecycle Manager on the host level with PowerCLI.

Activate vSphere Lifecycle Manager on a Standalone Host

$hostName = <host_ip_address_or_fqdn>
$vmhost = Get-Vmhost $hostName
$spec=Initialize-SettingsHostsEnablementSoftwareEnableSpec -SkipSoftwareCheck $false
Invoke-SetHostEnablementSoftwareAsync -Host $vmhost.ExtensionData.MoRef.Value -SettingsHostsEnablementSoftwareEnableSpec $spec

Retrieve vSphere Lifecycle Manager (vLCM) Image Profiles

You can retrieve vLCM images from a vCenter Server system based on different filters by using the Get-LcmImage cmdlet. You can pass IDs or a combination of name and version filters to the Get-LcmImage parameters.

List all types of vLCM images
Get-LcmImage
List only BaseImage (ESXi) vLCM images
Get-LCMImage -Type 'BaseImage'
List Only VendorAddOn vLCM images
Get-LCMImage -Type 'VendorAddOn'
List only Component vLCM images
Get-LCMImage -Type 'Component'
List only Package (Firmware) vLCM images
Get-LCMImage -Type 'Package'

View / Check Recommended Images

$vmhost = Get-Host -Name $hostName
Invoke-GetHostSoftwareRecommendations -Host $vmhost.ExtensionData.MoRef.Value

Retrieve a Host's Desired State

Get-VMHost -Name $hostName | Select-Object -Property Name, BaseImage, @{n='BaseImageVersion'; e={$_.BaseImage.Version}}, Components, VendorAddon, FirmwareAddons

Modify a Host's vLCM Desired State

$vLCMBaseImageu2 = Get-LCMImage -Version '7.0 GA - 15843807' -Type BaseImage
$vendorAddon = Get-LcmImage -Name 'NEC-addon-GEN' -Version '7.0.2-02'
$components = $components = Get-LcmImage -Id 'Component-<Component1 Name>/<Component1 Version>'
$firmwareAddon = Get-LcmImage -Id '<FirmwareAddOn_Id>'
Get-Host -Name $hostName | Set-Host -BaseImage $vLCMBaseImageu2 -VendorAddOn $vendorAddon -Component $components -FirmwareAddOn $firmwareAddon

Update a Host's vLCM Base Image

You cannot remove or downgrade an ESXi base image - you can only upgrade it. The following example demonstrates an upgrade of a host's desired state to ESXi 7.0 U2.
$vLCMBaseImageu2= Get-LcmImage -Version '7.0 U2a - 17867351' -Type BaseImage
Get-Host -Name $hostName | Set-Host -BaseImage $vLCMBaseImageu2

Remove a vLCM Vendor Add-on from a Host

Get-Host -Name $hostName | Set-Host -VendorAddOn $null
Note: You can add, replace, remove, upgrade, or downgrade a vendor add-on.

Update a Host's vLCM Component List

Replace a Component list with a new one.
$components = Get-LcmImage -Id 'Component-<Component1 Name>/<Component1 Version>', 'Component-<Component2 Name>/<Component2 Version>'
Get-Host -Name $hostName | Set-Host -Component $components
Note: To remove all components, use Set-Cluster -Component $null

Add a vLCM Firmware Add-on

$firmwareAddon = Get-LcmImage -Id '<FirmwareAddOn_Id>'
Get-Host -Name $hostName | Set-Host -FirmwareAddOn $firmwareAddon
Note: You can add, replace, remove, upgrade, or downgrade a firmware add-on.

Check Compliance of a Host

Compare the current image on the standalone host against the desired image that you specified and define the compatibility status of the host.
$vmhost = Get-Host -Name $hostName
Invoke-ScanHostSoftwareAsync -Host $vmhost.ExtensionData.MoRef.Value

Pre-check a Host

Run a remediation pre-check on the host to ensure software and hardware compatibility with the desired software specification.
$spec = Initialize-SettingsHostsSoftwareCheckSpec -Commit <MyCommit>
$vmhost = Get-Host -Name $hostName
Invoke-CheckHostSoftwareAsync -Host $vmhost.ExtensionData.MoRef.Value -SettingsHostsSoftwareCheckSpec $spec

Stage a Host

Stage the desired state on a standalone ESXi host.
$spec = Initialize-SettingsHostsSoftwareStageSpec -Commit <myCommit>
$vmhost = Get-Host -Name $hostName
Invoke-StageHostSoftwareAsync -Host $vmhost.ExtensionData.MoRef.Value -SettingsHostsSoftwareStageSpec $spec

Remediate a Host

Apply the desired state on a standalone host, whose current state is different from the desired software specification.
$spec = Initialize-SettingsHostsSoftwareApplySpec -AcceptEula $true
$vmhost = Get-Host -Name $hostName
Invoke-ApplyHostSoftwareAsync -Host $vmhost.ExtensionData.MoRef.Value -SettingsHostsSoftwareApplySpec $spec