Hi All,
I could greatly use some assistance, I am looking to pull a report via PowerCLI with the following information, this would be an example. I'd like output for the VM, all drives, their associated datastores, disk layout type, the amount of storage allocated to that vmdk, the amount of disk the guest is actually using.
VM Name | Drive | Datastore | Disk Layout | Storage Allocated (GB) | Guest Disk Usage (GB) |
TEST01 | C: | T1-DS-001 | THIN | 100 | 40.5 |
TEST01 | 😧 | T1-DS-002 | THICK | 400 | 101.3 |
Thank you so much in advance!
That information is coming from inside the guest OS.
In fact you need to have the VMware Tools installed to get that information.
The guest OS has not notion of the underlying vDisks, and hence the datastore.
In specific case, for example 1 partition on 1 vDisk, you can do this.
See for example Arnim's post called PowerCLI: Match VM and Windows harddisks – Part 2
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I'm afraid there is no fool-proof method to link the partitions defined in the guest OS to the VMDKs.
One difficulty is for example a VMDK on which, in the guest OS, 2 partitions are created.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for the quick reply, I did find this
ForEach
(
$VM
in
Get-VM
){(
$VM
.Extensiondata.Guest.Disk | Select @{N=
"Name"
;E={
$VM
.Name}},DiskPath, @{N=
"Capacity(MB)"
;E={
[math]
::Round(
$_
.Capacity/ 1MB)}}, @{N=
"Free Space(MB)"
;E={
[math]
::Round(
$_
.FreeSpace / 1MB)}}, @{N=
"Free Space %"
;E={
[math]
::Round(((100* (
$_
.FreeSpace))/ (
$_
.Capacity)),0)}})}
I was looking to take it one step further and add the datastore for each drive output.
That information is coming from inside the guest OS.
In fact you need to have the VMware Tools installed to get that information.
The guest OS has not notion of the underlying vDisks, and hence the datastore.
In specific case, for example 1 partition on 1 vDisk, you can do this.
See for example Arnim's post called PowerCLI: Match VM and Windows harddisks – Part 2
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference