This KB article's purpose is to document a change in behaviour of the VMware.ImageBuilder module of PowerCLI with respect to creating image profiles with the New-EsxImageProfile cmdlet.
Invoking VMware.ImageBuilder's New-EsxImageProfile cmdlet results in errors containing "Profile <profile-name> is missing component(s)...".
There is no direct resolution to the issue, as this is the expected behaviour.
Please find below the script that provides sample logic that resolves a list of component names to the respective VIBs that they are comprised of. It assumes that a valid depot is provided and will report warnings if any of the requested components could not be resolved using the given depot. The resulting list of VIBs can then be provided in the -SoftwarePackage field of the New-EsxImageProfile cmdlet when creating a new profile.
##
# This is a script which receives a depot and a list of component names and
# resolves them into the individual VIB names, those components are comprised of.
#
# This script assumes that you have setup the VMware.ImageBuilder PowerCLI module
# properly.
##
param(
# List of depots (offline/online) containing the components/VIBs.
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string]
$depot,
# List of component names that need to be resolved.
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string[]]
$components
)
Import-Module VMware.ImageBuilder
# Sanitize requested components.
$components = $components | Sort-Object | Get-Unique
$reqCompStr = $components -Join ", "
Write-Host "Request to resolve the following components: $reqCompStr"
Write-Host "Adding ESXi depot '$depot'..."
Add-EsxSoftwareDepot $depot
$vibIds = @()
$unresolvedComps = @()
Write-Host "Resolving components..."
$depotComponents = Get-DepotComponents -Depot $depot
foreach ($compName in $components) {
$compId = $null
Write-Host "Resolving component '$compName'..."
foreach ($comp in $depotComponents) {
if ($comp.Name -eq $compName) {
$compId = $comp.Id
}
}
if ($compId -eq $null) {
Write-Warning "Component '$compName' not found!"
$unresolvedComps += $compName
continue
}
$compVibs = (Get-DepotComponents -Depot $depot -Id $compId).VibIds
$vibStr = $compVibs -Join ", "
Write-Host "VIBs part of component '$compName': $vibStr"
$vibIds += $compVibs
}
# Resolve VIB IDs to VIB names.
$vibNames = @()
$allVibs = Get-EsxSoftwarePackage
foreach ($id in $vibIds) {
$vibNames += ($allVibs | Where {$_.Guid -eq $id}).Name
}
if ($unresolvedComps.Count -gt 0) {
$unresolvedCompsStr = $unresolvedComps -Join ", "
Write-Warning "Failed to resolve components: $unresolvedCompsStr"
}
$vibNames = $vibNames | Sort-Object | Get-Unique
$vibsStr = $vibNames -join ", "
Write-Host "Resolved components' VIBs: $vibsStr"