VMware Cloud Community
jesse_gardner
Enthusiast
Enthusiast
Jump to solution

Quirk with set-harddisk -storageformat?

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?

0 Kudos
1 Solution

Accepted Solutions
admin
Immortal
Immortal
Jump to solution

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

View solution in original post

0 Kudos
5 Replies
admin
Immortal
Immortal
Jump to solution

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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

admin
Immortal
Immortal
Jump to solution

That's right, thanks for the clarification Luc.

0 Kudos
jesse_gardner
Enthusiast
Enthusiast
Jump to solution

Thanks, guys.  I can certainly work around this, now that I understand.

0 Kudos
jesse_gardner
Enthusiast
Enthusiast
Jump to solution

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

0 Kudos