Starting with vSphere 7.0 and VMware PowerCLI 12.1.0, you can create and manage vSphere Lifecycle Manager clusters with PowerCLI.
Cluster-level Functionality Starting from vSphere 7.0 and VMware PowerCLI 12.1.0
Starting from vSphere 7.0 and
VMware PowerCLI 12.1.0, some of the cluster-level operations that you can perform are:
- Create a vSphere Lifecycle Manager cluster with a desired state.
- View desired state elements:
- ESXi version
- Vendor add-ons
- Firmware/ drivers
- Components
- View/ check recommended images.
- Add hosts to a cluster.
- Retrieve a cluster with a vLCM desired state.
- Update a cluster's ESXi base image.
- Add, remove, replace, upgrade, or downgrade a vendor add-on on a cluster.
- Update a cluster's vSphere Lifecycle Manager component list.
- Add, remove, replace, upgrade, or downgrade a firmware add-on to a cluster.
- Modify the desired state of a vSphere Lifecycle Manager cluster.
- Convert a vSphere Update Manager cluster into a vSphere Lifecycle Manager cluster.
- Check compliance of the ESXi hosts on a cluster.
- Apply the desired state on hosts in a cluster, whose current state is different from the desired specification (remediate cluster).
- Export a desired state from a cluster.
- Import a desired state to a cluster.
- View hardware compatibility.
Cluster-level Functionality Starting from vSphere 8.0 and VMware PowerCLI 13.1.0
Starting from vSphere 8.0 and VMware PowerCLI 13.1.0, some of the new cluster-level operations that you can perform are:
- Update hardware compatibility list.
- View parallel remediation settings.
- Activate/ deactivate parallel remediation.
- Create or modify a cluster by importing an ESXi base image.
- Retrieve pre-check results.
- Stage a cluster.
Sample Scripts for vSphere Lifecycle Manager Cluster-Level Operations
The following scripts demonstrate how you can use vSphere Lifecycle Manager on the cluster level with PowerCLI.
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 (FirmwareAddOn) vLCM images
Get-LCMImage -Type 'Package'
Create a New Cluster with a vLCM Desired State
You can create a new
vSphere Lifecycle Manager cluster in the following ways:
- By specifying parameters from the VMware depots:
$clusterName= Read-Host -Prompt 'Provide the cluster Name' $vLCMBaseImage = Get-LCMImage -Version '7.0 GA - 15843807' -Type BaseImage $vendorAddon = Get-LcmImage -Name 'NEC-addon-GEN' -Version '7.0.2-02' New-Cluster -Location Datacenter -Name $clusterName -BaseImage $vLCMBaseImage -VendorAddOn $vendorAddon -HAEnabled -DrsEnabled
- By importing a vLCM desired state spec.
New-Cluster -Name 'MyCluster' -Location <MyDatacenter> | Import-LcmClusterDesiredState -LocalSpecLocation F:\Image\desired-state-spec.json
Retrieve a Cluster's Desired State
Get-Cluster -Name $clusterName | Select-Object -Property Name, BaseImage, @{n='BaseImageVersion'; e={$_.BaseImage.Version}}, Components, VendorAddon, FirmwareAddons
Update a Cluster'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 cluster's desired state to
ESXi 7.0 U2.
$vLCMBaseImageu2 = Get-LcmImage -Version '7.0 U2a - 17867351' -Type BaseImage Get-Cluster -Name $clusterName | Set-Cluster -BaseImage $vLCMBaseImageu2
Remove a vLCM Vendor Add-on from a Cluster
Get-Cluster -Name $clusterName | Set-Cluster -VendorAddOn $null
Note: You can add, replace, remove, upgrade, or downgrade a vendor add-on.
Update a Cluster'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-Cluster -Name $clusterName | Set-Cluster -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-Cluster -Name $clusterName | Set-Cluster -FirmwareAddOn $firmwareAddon
Note: You can add, replace, remove, upgrade, or downgrade a firmware add-on.
Modify a Cluster's vLCM Desired State
$vLCMBaseImage = Get-LCMImage -Version '7.0 U3f - 20036589' $vendorAddOn = get-lcmimage -type vendoraddon -Version '703.0.0.10.9.0-11' Set-Cluster 'vlcm-cluster-pcli' -BaseImage $vLCMBaseImage -VendorAddOn $vendorAddOn
Convert a vSphere Update Manager Cluster to a vSphere Lifecycle Manager Cluster
Convert a
vSphere Update Manager cluster to a
vSphere Lifecycle Manager cluster.
$vLCMBaseImage = Get-LCMImage -Version '7.0 U3f - 20036589' $vendorAddOn = get-lcmimage -type vendoraddon -Version '703.0.0.10.9.0-11' Set-Cluster 'vum-cluster' -BaseImage $vLCMBaseImage -VendorAddOn $vendorAddOn
Check Cluster Compliance
Check the compliance of the hosts on the cluster against the cluster's desired state.
Get-Cluster -Name $clusterName | Test-LcmClusterCompliance
Remediate a Cluster
Apply the desired state to the hosts in the cluster, whose current state is different from the desired software specification.
Get-Cluster -Name $clusterName | Set-Cluster -Remediate -AcceptEULA
Export a vLCM Desired State
Get-Cluster -Name $clusterName | Export-LcmClusterDesiredState -Destination 'F:\Image' -ExportOfflineBundle -ExportIsoImage
Import a vLCM Desired State
Import-LcmClusterDesiredState -Cluster 'ExistingCluster' -LocalSpecLocation F:\Image\desired-state-spec.json -Verbose
View / Check Recommended Images
Generate a desired state recommendation of a
vSphere Lifecycle Manager cluster.
- Based on the latest ESXi base image version.
Get-LcmClusterDesiredStateRecommendation 'lcm-cluster' -Latest
- Based on the latest patch or update of the currently installed ESXi base image version.
Get-LcmClusterDesiredStateRecommendation 'lcm-cluster' -Current
View Hardware Compatibility
Get-LcmHardwareCompatibility -Cluster 'lcm-cluster'
Update Hardware Compatibility List
Invoke-DownloadHclCompatibilityDataAsync
View Parallel Remediation Settings
Invoke-GetDefaultsClustersPoliciesApply Invoke-GetClusterPoliciesApply -Cluster $clusterId
Activate or Deactivate Parallel Remediation
Activate or deactivate parallel remediation with the maximum number of concurrent remediations.
$ParallelRemediationSetting = Initialize-SettingsDefaultsClustersPoliciesParallelRemediationAction -Enabled $true -MaxHosts $maxHostCount $PolicySpec = Initialize-SettingsDefaultsClustersPoliciesApplyConfiguredPolicySpec -ParallelRemediationAction $ParallelRemediationSetting Invoke-SetDefaultsClustersPoliciesApply -Cluster $clusterID -SettingsClustersPoliciesApplyConfiguredPolicySpec $PolicySpec
Create a Cluster by Importing an Image from a Standalone Host
Extract a software specification from an
ESXi host and import it into the software depot.
$SettingsDepotsOfflineHostCredentials = Initialize-SettingsDepotsOfflineHostCredentials -HostName "MyHostName" -UserName "MyUserName" -Password "MyPassword" -Port 0 -SslThumbPrint "MySslThumbPrint" $SettingsDepotsOfflineConnectionSpec = Initialize-SettingsDepotsOfflineConnectionSpec -AuthType "USERNAME_PASSWORD" -HostCredential $SettingsDepotsOfflineHostCredentials Invoke-CreateFromHostDepotsOfflineAsync -SettingsDepotsOfflineConnectionSpec $SettingsDepotsOfflineConnectionSpecThen use New-Cluster or Set-Cluster to create or modify a cluster's desired state from the returned software spec.
Retrieve Pre-check Results
Return the last remediation pre-check results.
$cluster = Get-Cluster -Name <cluster_name> Invoke-GetClusterSoftwareReportsLastCheckResult -Cluster $cluster.ExtensionData.MoRef.Value
Stage a Cluster
Stage a desired software specification on a
vSphere Lifecycle Manager cluster.
$SettingsClustersSoftwareStageSpec = Initialize-SettingsClustersSoftwareStageSpec -Commit <myCommit> -Hosts <MyHosts> Invoke-StageClusterSoftwareAsync -Cluster <MyCluster> -SettingsClustersSoftwareStageSpec $spec