I'm trying to move individual VM disks based on their datastore, irrespective of what VM they're attached to. I can give a bigger picture of my task if asked, but I'm not sure its relevant.
When I get the disk object in the pipeline from Get-Datastore:
Get-Datastore "datastorename" | Get-HardDisk | Select -First 1 | Set-HardDisk -Datastore (Get-Datastore "newdatastore") -StorageFormat Thin -Confirm:$false
...I get this error:
Set-HardDisk : 1/13/2011 1:46:18 PM Set-HardDisk Transformation of the disk storage format is not supported for unattached disks.
However, when I get the disk object in the pipeline from Get-VM:
Get-VM "vmname" | Get-HardDisk | Select -First 1 | Set-HardDisk -Datastore (Get-Datastore "newdatastore") -StorageFormat Thin -Confirm:$false
...it works. And its the same VM/disk file I'm dealing with in both cases.
Strange?
Hi Jesse,
When a hard disk is directly retrieved from a datastore there isn't sufficient information to determine whether it's attached to a VM or not. And for disks that are not attached to a VM we don't support changing the storage format. You need to retrieve the disks from the VMs in order to do that.
Regards,
Dimitar
PowerCLI team
Hi Jesse,
When a hard disk is directly retrieved from a datastore there isn't sufficient information to determine whether it's attached to a VM or not. And for disks that are not attached to a VM we don't support changing the storage format. You need to retrieve the disks from the VMs in order to do that.
Regards,
Dimitar
PowerCLI team
Perhaps a further clarification, this is not a PowerCLI limitation.
The underlying SDK method, RelocateVM_Task, is a method that is based on the VirtualMachine object.
So you need the guest to perform the transformation of the disk.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That's right, thanks for the clarification Luc.
Thanks, guys. I can certainly work around this, now that I understand.
Another quirk, in my opinion, though I understand these are related and were probably a concious choice. The CapacityKB for a Thin disk is reported differently (Thick size vs true Thin size) depending on whether you acquire the disk object from Get-Datastore or Get-VM. While I kind of understand, this only leads to confusion in my opinion. Certainly lends itself to improvement in future versions of PowerCLI.
PS C:\> Get-Datastore "datastorename" | Get-HardDisk
CapacityKB Persistence Filename
---------- ----------- --------
7829504 Unknown [SAN-TSTVMFS-01] testxp2/testxp2.vmdk
______________________________________________________________________________
PS C:\> get-vm "testxp2" | get-harddisk
CapacityKB Persistence Filename
---------- ----------- --------
31457280 Persistent [SAN-TSTVMFS-01] testxp2/testxp2.vmdk