Remove vApp Template With No Catalog Item Link

First… Did you know that vApp Templates and Catalog Items are two different things in vCloud Director? If so, did you know that you can have a vApp Tempalte that does not link to a catalog item? Finally, you can’t have a Catalog Item without a vApp Tempalte backing though.

Well I guess you could. If you manage to get one of those, you will want to follow my guide on fixing that here .

Okay back to detecting if you have a vApp Template that is not mapped to a Catalog Item. To detect these ‘hung’ vApp Templates run the following script as a ‘system administrator’

1$VappTemplates = Search-Cloud -QueryType AdminVappTemplate
2
3foreach ( $VappT in $VappTemplates ) { $vAppTemplate = Get-CIVAppTemplate -ID $VappT.Id
4  $vapptid = $vapptemplate.id
5  $CatItem = Search-Cloud -QueryType AdminCatalogItem -Filter Entity==$VappTId
6  if ( !$CatItem ) { Write-Host "Get-CIVappTemplate -ID $($vAppTemplate.Id) " }
7}

This will procduce an out put of ‘Get-CIVappTemplate’ and the ID of the hung vApp Template. It is up to you to pick what to do with that hung vApp Template. I recommend removing them and re-creating whatever they were. To do that append this to the output and run it in the same PowerShell window:

1Remove-CIVappTemplate -RemoveCatalogItem $False

Detecting and Removing Invalid vApps
Relocating a VM in vCloud Director