It’s easy finding the disks used by a VM. Just check its settings via the client or use PowerCLI.
1 2 3 4 5 6 |
PowerCLI C:\> Get-VM VS-EXCH01 | select -ExpandProperty HardDisks CapacityGB Persistence Filename ---------- ----------- -------- 40.000 Persistent [DATA02] VS-EXCH01/VS-EXCH01.vmdk 250.000 Persistent [DATA02] VS-EXCH01/VS-EXCH01_1.vmdk |
Can’t do the same for a template though as the Get-Template
output has no similar property.
1 2 3 4 5 6 7 8 9 10 11 |
PowerCLI C:\> Get-Template "2012R2_Gold (Aug2014)" | fl * FolderId : Folder-group-v1444 DatastoreIdList : {Datastore-datastore-1593} Name : 2012R2_Gold (Aug2014) ExtensionData : VMware.Vim.VirtualMachine Id : VirtualMachine-vm-9981 Uid : /VIServer=domain\admin@vcenter01:443/VirtualMachine=VirtualMachine-vm-9981/ Client : VMware.VimAutomation.ViCore.Impl.V1.VimClient HostId : HostSystem-host-1370 |
But then I came across Get-HardDisk
:
1 2 3 4 5 6 |
PowerCLI C:\> Get-Template "2012R2_Gold (Aug2014)" | Get-HardDisk CapacityGB Persistence Filename ---------- ----------- -------- 50.000 Persistent ...012R2_Gold (Aug2014)/2012R2_Gold (Aug2014).vmdk 10.000 Persistent ...2R2_Gold (Aug2014)/2012R2_Gold (Aug2014)_1.vmdk |
Sweet! Same command works for templates (as above) and VMs:
1 2 3 4 5 6 |
PowerCLI C:\> Get-VM VS-EXCH01 | Get-HardDisk CapacityGB Persistence Filename ---------- ----------- -------- 40.000 Persistent [RIYADHDATA02] VS-EXCH01/VS-EXCH01.vmdk 250.000 Persistent [RIYADHDATA02] VS-EXCH01/VS-EXCH01_1.vmdk |
That’s all. Hope this helps someone.