Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 244595

Re: BUG?: Remove-HardDisk / Remove-VM [NOT DELETING]

$
0
0

I've now upgraded and have the same problem.

 

I think this issue is down to how the VM is being cloned by my script:

 

 

 

 

 

foreach($vmin$vms)

{

foreach($devin$vmmor.Config.Hardware.Device)

{

if ($dev.DeviceInfo.Label-eq"Hard disk 1") #Just OS Disk

{

#Remove old Clone

$oldVM=Get-VM-Name$targetVMname

Get-HardDisk-VM$oldVM | Remove-HardDisk-DeletePermanently-Confirm:$false

Remove-VM-VM$oldVM-DeletePermanently:$true-Confirm:$false

 

 

#Define the clone specification

$vmclonespec=New-ObjectVMware.Vim.VirtualMachineCloneSpec

#Get information about the hard disk device

$vmclonespec.config=New-ObjectVMware.Vim.VirtualMachineConfigSpec

## Define what to change in the cloned VM's Configuration

 

$vmclonespec.config.deviceChange= @()

$vmclonespec.config.deviceChange+=New-ObjectVMware.Vim.VirtualDeviceConfigSpec

$vmclonespec.config.deviceChange[0].device =New-ObjectVMware.Vim.VirtualDevice

$vmclonespec.config.deviceChange[0].device.key =$dev.Key

$vmclonespec.config.deviceChange[0].device.unitnumber =$dev.UnitNumber

$vmclonespec.config.deviceChange[0].operation ="remove"

$vmclonespec.location=New-ObjectVMware.Vim.VirtualMachineRelocateSpec

$vmclonespec.powerOn=$false

$vmclonespec.template=$false

$ref=$vmmor.CloneVM_Task($targetLocation.MoRef, $targetVMname, $vmclonespec)

 

}

}

 

 

 

 

}

 

If I clone in vSphere - this script will delete the VM no problems.

If I clone using the script - this script AND vSphere will still leave the VMDK behind.

 

Any ideas?


Viewing all articles
Browse latest Browse all 244595

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>