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?
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.
I have since managed to find this:
which lists all shadow VMs but now the question is how to delete these records?
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
This is as simple as it gets.