In this blog I will try to explain how you can delete locked Instant-Clone objects. My colleague Marc already explained how you can do it in the GUI, so if you are not familiar with scripting/PowerShell then this blog is a good alternative.

IMPORTANT: Making changes to the MOB (internal API) is not supported and used at own risk. Not sure what u are doing? contact VMware support!

So how do we start? In my script I made some assumptions like the use of dvSwitches and vlan IDs used in the names of your distributed port groups.
Step 1 is to login to the vCenter and the MOB url.

$mob_url = "https://$vCenter/mob/?moid=AuthorizationManager&method=enableMethods"
$results = Invoke-WebRequest -Uri $mob_url -SessionVariable vmware -Credential $credential -Method GET
Connect-VIServer $vCenter -Credential $credential

Step 2 is to get de MoRef IDs from the VMs in your vlan.

$dvswitch = 'dvs-production'
$vlanId = ''
$vlan = (Get-VDPortgroup -VDSwitch $dvSwitch).where{$ -match $vlanId}
$VMs = $vlan.extensionData.vm.value

Step 3 is to build the body to execute the API call for each VM.

$EnableMethod = 'Destroy_Task'
$null = $results -match 'name="vmware-session-nonce" type="hidden" value="?([^\s^"]+)"'
$sessionnonce = $matches[1]
$body = @"
# Second request using a POST and specifying our session from initial login + body request
$results = Invoke-WebRequest -Uri $mob_url -WebSession $vmware -Method POST -Body $body

The result is that for a cp-template, cp-replica or cp-parent the option “delete form disk” becomes available in vCenter.
So now you can delete the linked-clone leftovers.

The full PowerShell script (function) can be found here:



Leave a Reply

Your email address will not be published. Required fields are marked *