This article explains the steps to remove ESXi components imported into vSphere Lifecycle Manager (vLCM) using PowerCLI.
VMware vCenter Server
We recommend taking an offline snapshot of the vCenter Server Appliance as a rollback point in case of failure. For best practices on creating snapshots for the vCenter Server Appliance, please refer to Snapshot Best Practices for vCenter Server Virtual Machines.
If the component is used in a baseline, please remove that baseline first. For instructions on how to delete a baseline, please refer to Delete Baselines and Baseline Groups.
Connect to vCenter Server using Connect-CisServer in PowerCLI.
Connect-CisServer -Server <IP Address or FQDN of vCenter Server> -Username <Username> -Password <Password> -Force
Run the following script to list all ComponentIds.
$owner = '[email protected]'
$offlineDepotService = Get-CisService -Name com.vmware.esx.settings.depots.offline
$allComponents = $offlineDepotService.list()
$results = @()
foreach ($component in $allComponents.GetEnumerator())
{
if($component.Value.owner.toLower() -eq $owner) {
$tmp = [PSCustomObject] @{
ComponentId = $component.Key
}
$results += $tmp
}
}
$results
When you run the script, you will get results like the following:
ComponentId
-----------
31EAF1F762D76470C952##################F7
815D3DB5985161B5F5F7##################C5
In the following steps, we will use the ComponentIds obtained from this script.
Run the following script to show the details of each component. Replace the componentId in the first line with the one obtained in Step 2.
$componentId = "31EAF1F762D76470C952##################F7"
$offlineDepotContentService = Get-CisService -Name com.vmware.esx.settings.depots.offline.content
$componentDetails = $offlineDepotContentService.get($componentId).metadata_bundles
$results = @()
foreach ($componentDetail in $componentDetails.GetEnumerator())
{
foreach ($component in $componentDetail.Value.independent_components.GetEnumerator()) {
$tmp = [PSCustomObject] @{
ComponentName = $component.Key
ComponentVersion = $component.Value.versions.version
ComponentDirectory = $componentDetail.Key
ComponentFile = $componentDetail.Value.file_name
}
$results += $tmp
}
}
$results
You will get results like the following:
ComponentName ComponentVersion ComponentDirectory ComponentFile
------------- ---------------- ------------------ -------------
VMware-VM-Tools {12.5.3.24819442-24820517, 12.5.3-6.X.24819442} vmw metadata-151.zip
Make sure that the componentId specified in the script matches the name of the component you want to remove. If it doesn’t, replace the componentId with a different one and run the script again.
Next, delete the component using the following command. A "Delete depot" task will be created in vCenter Server, and the component will be removed from vLCM.
$componentId = '31EAF1F762D76470C952##################F7'
$offlineDepotService = Get-CisService -Name com.vmware.esx.settings.depots.offline
$offlineDepotService.'delete$task'($componentId)
If the component is used in one or more baselines, the deletion task will fail with "The content of the specified depot is being referenced by some baselines or desired status." If you encounter this error, please check whether the component is being used in any baseline or baseline group. For instructions on deleting baselines, please refer to the link in the Before You Begin section of this article.