VMware Cloud Community
FirstByte
Enthusiast
Enthusiast

How to delete vCloud Director SHADOW-VM using PowerCLI

Does anyone know how to delete a shadow-vm using PowerCLI?

After creating a vApp Template, we copy it across to other datastores (this step is scripted already). However, doing the copy, creates shadow VMs under the source vApp Template (40x VMs for our environment), however we have been unable to script the deletion of these shadow VMs following the completion of the copy.

Any help would be appreciated.

Thanks

Darren

Tags (2)
Reply
0 Kudos
4 Replies
jasoncain_22
Enthusiast
Enthusiast

Do you always need to perform a 'copy' job? Why not select the 'move' option instead to avoid this altogether?

Otherwise, do you want to include a step to delete the shadow-vm within the same script or as a 1-off script?

Reply
0 Kudos
FirstByte
Enthusiast
Enthusiast

Hi Jason

Thanks for the reply. Yes, in our situation we do need to copy the Temapltes across our datastores. This is so that when we deploy from those templates on the other datastores, then the environments/vApps will be thin provisioned (linked clones) from the template that resides on their "local" datastore. It also makes deployments MUCH faster when deploying vapps to same datastore.

Ideally, we'd look to include the deletion of shadow vms in the existing script we have, to be run after the copies had completed. Having said that, I can see it also being run outside of the main script, if we look to do a cleanup of any rogue shadows.

Thanks

Darren

Reply
0 Kudos
FirstByte
Enthusiast
Enthusiast

Hi Jason

I have since managed to find this:

Search-Cloud AdminShadowVm

which lists all shadow VMs but now the question is how to delete these records?

Reply
0 Kudos
bdmpastx
Contributor
Contributor

I know this is an old post but I figured I would share.

This code will get rid of all the shadow VMs. If you want to get rid of ones for particular templates, you will need to do some more filtering on the results.

#Get all the shadow VMs:

$vms = search-cloud adminshadowvm

#loop through all the VMs

foreach ($vm in $vms)[

     $vmv = $vm|get-ciview

     #vmv.delete()

     }

This is as simple as it gets.

Reply
0 Kudos