Hi all,
I'm trying to list all my vm's and all their associated vmdk files. I'm currently running this:
get-vm | sort-object Name | get-harddisk which returns the following list:
CapacityKB / Persistence / Filename
What I'm trying to achieve is:
VM Name / CapacityKB / Filename
Any ideas what I'm doing wrong?
Thanks
Are you using the latest PowerCLI build ?
Do
Get-PowerCLIVersion
That should return
PowerCLI Version
----------------
VMware vSphere PowerCLI 4.1 U1 build 332441
You can use the Get-Member cmdlet to see the level 1 properties of an object
Get-VM | Get-Harddisk | Get-Member
To see the complete object, you could do
Get-VM MyVM | Get-Harddisk | Format-Custom -Depth 2
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You have ot use a Select-Object cmdlet to get the desired properties.
If you don't, you get the default display for the Harddisk object.
Like this
get-vm | sort-object Name | get-harddisk | Select @{N="VM name";E={$_.Parent.Name}},CapacityKB,Filename
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for the response. I ran that and came back with the column/format i'm looking for with the exception of "VM Name" is blank. Also, how do you know what object to call (ie, how did you know how to specify the name "Parent.Name"?) is there some command to list all available objects?
Are you using the latest PowerCLI build ?
Do
Get-PowerCLIVersion
That should return
PowerCLI Version
----------------
VMware vSphere PowerCLI 4.1 U1 build 332441
You can use the Get-Member cmdlet to see the level 1 properties of an object
Get-VM | Get-Harddisk | Get-Member
To see the complete object, you could do
Get-VM MyVM | Get-Harddisk | Format-Custom -Depth 2
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yep, my version was outdated. I installed latest version and viola...the names are listed. Thank you so much for your insight and help.
Luc,
many thanks for sharing the knowledge here, however is it possibleto list which VMDK that each RDM partition attached to a VM ?
I tried using your modified script:
get-vm ExcMbx01-vm | sort-object Name | get-harddisk | Select @{N="VM name";E={$_.Parent.Name}},@{N="Capacity(KB)";E={[math]::truncate($_.CapacityKB / 1KB)}},Filename | ft -AutoSize
and it is still too hard forme to match it with the Windows Partition name because the result is as follows from the script above:
VM name Capacity(KB) Filename------- ------------ --------ExcMbx01-VM 65536 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM.vmdkExcMbx01-VM 61440 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_1.vmdkExcMbx01-VM 133120 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_2.vmdkExcMbx01-VM 133120 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_10.vmdkExcMbx01-VM 133120 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_11.vmdkExcMbx01-VM 133120 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_3.vmdkExcMbx01-VM 133120 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_4.vmdkExcMbx01-VM 133120 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_5.vmdkExcMbx01-VM 133120 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_6.vmdkExcMbx01-VM 133120 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_7.vmdkExcMbx01-VM 133120 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_8.vmdkExcMbx01-VM 133120 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_9.vmdkExcMbx01-VM 30720 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_12.vmdkExcMbx01-VM 30720 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_20.vmdkExcMbx01-VM 30720 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_21.vmdkExcMbx01-VM 30720 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_13.vmdkExcMbx01-VM 30720 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_14.vmdkExcMbx01-VM 30720 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_15.vmdkExcMbx01-VM 30720 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_16.vmdkExcMbx01-VM 30720 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_17.vmdkExcMbx01-VM 30720 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_18.vmdkExcMbx01-VM 30720 [VMFS_FPE_01_NOT_REPLICATED] ExcMbx01-VM/ExcMbx01-VM_19.vmdkwhile this is the script result that I have to list the Guest OS VM information:
ExcMbx01 C: - disk size - * (64 GB), used space (40.25 GB), free space (23.75 GB), percentage free space = 37.11 %
ExcMbx01 E: - disk size - SG1 Data (130 GB), used space (82.33 GB), free space (47.67 GB), percentage free space = 36.67 %
ExcMbx01 F: - disk size - SG2 Data (130 GB), used space (73.84 GB), free space (56.16 GB), percentage free space = 43.2 %
ExcMbx01 G: - disk size - SG3 Data (130 GB), used space (74.66 GB), free space (55.34 GB), percentage free space = 42.57 %
ExcMbx01 H: - disk size - SG4 Data (130 GB), used space (91.68 GB), free space (38.32 GB), percentage free space = 29.48 %
ExcMbx01 I: - disk size - SG5 Data (130 GB), used space (69.06 GB), free space (60.94 GB), percentage free space = 46.88 %
ExcMbx01 J: - disk size - SG6 Data (130 GB), used space (74.59 GB), free space (55.41 GB), percentage free space = 42.62 %
ExcMbx01 K: - disk size - SG7 Data (130 GB), used space (81.04 GB), free space (48.96 GB), percentage free space = 37.66 %
ExcMbx01 L: - disk size - SG8 Data (130 GB), used space (62.35 GB), free space (67.65 GB), percentage free space = 52.04 %
ExcMbx01 M: - disk size - SG9 Data (130 GB), used space (86.28 GB), free space (43.72 GB), percentage free space = 33.63 %
ExcMbx01 N: - disk size - SG10 Data (130 GB), used space (66.76 GB), free space (63.24 GB), percentage free space = 48.65 %
ExcMbx01 O: - disk size - Old SG10 Logs (30 GB), used space (0.120000000000001 GB), free space (29.88 GB), percentage free space = 99.61 %
ExcMbx01 P: - disk size - SG1 Logs (30 GB), used space (1.69 GB), free space (28.31 GB), percentage free space = 94.36 %
ExcMbx01 Q: - disk size - SG2 Logs (30 GB), used space (1.15 GB), free space (28.85 GB), percentage free space = 96.18 %
ExcMbx01 R: - disk size - SG3 Logs (30 GB), used space (0.989999999999998 GB), free space (29.01 GB), percentage free space = 96.69 %
ExcMbx01 S: - disk size - SG4 Logs (30 GB), used space (1.07 GB), free space (28.93 GB), percentage free space = 96.42 %
ExcMbx01 T: - disk size - SG5 Logs (30 GB), used space (0.98 GB), free space (29.02 GB), percentage free space = 96.72 %
ExcMbx01 U: - disk size - SG6 Logs (30 GB), used space (1.88 GB), free space (28.12 GB), percentage free space = 93.75 %
ExcMbx01 V: - disk size - SG7 Logs (30 GB), used space (1 GB), free space (29 GB), percentage free space = 96.66 %
ExcMbx01 W: - disk size - SG8 Logs (30 GB), used space (0.870000000000001 GB), free space (29.13 GB), percentage free space = 97.09 %
ExcMbx01 X: - disk size - SG9 Logs (30 GB), used space (1.4 GB), free space (28.6 GB), percentage free space = 95.34 %
ExcMbx01 Y: - disk size - SG10 Logs (60 GB), used space (0.920000000000002 GB), free space (59.08 GB), percentage free space = 98.47 %
any suggestion and idea would be greatly appreciated.
Thanks