VMware Cloud Community
Godwin_Christop
Enthusiast
Enthusiast

VM hard disk usage and free space.

Hello,

I want a script that can pull VM hard disk usage, not on the partition front but on the hard disk front.
I have a script that calls "(get-vm).extensiondata.layoutex.file" and get the VMDK size but I found it to be not so accurate. if there is a possibility to get vm guest hard disk(not partition) usage that will solve the issue for me. 

Thanks in Advance 😄

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership

What exactly did you do with the data in LayoutEx.File?
Which inaccuracy did you notice?
I used the same property in yadr – A vdisk reporter, which seems to work for me.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Godwin_Christop
Enthusiast
Enthusiast

HI @LucD 

Thanks for the Reply,

my requirement is to get the hard disk usage on the hard disk front.

 

get-vm DRaaS-vCenter| Get-VMGuest -PipelineVariable guest |
where{$_.Disks -ne $null} |
ForEach-Object -Process {
$_.Disks | ForEach-Object -Process {
New-Object PSObject -Property ([ordered]@{ Server = $guest.VM.Name
 Path = $_.Path
CapacityGB = [math]::round($_.CapacityGB)
FreeSpaceGB = [math]::round($_.FreeSpaceGB)
 Percent = [int]($_.FreeSpaceGB/$_.CapacityGB * 100)
})}}


Server : DRaaS-vCenter
Path : C:\
CapacityGB : 80
FreeSpaceGB : 38
Percent : 47

 

(get-vm DRaaS-vCenter).extensiondata.layoutex.file |?{$_.name -match ".vmdk"}


Key : 4
Name : [ADAMA-STD-G200-DS07:02] DRaaS-vCenter/DRaaS-vCenter.vmdk
Type : diskDescriptor
Size : 0
UniqueSize : 0
BackingObjectId :
Accessible : True

Key : 5
Name : [ADAMA-STD-G200-DS07:02] DRaaS-vCenter/DRaaS-vCenter-flat.vmdk
Type : diskExtent
Size : 53520367616
UniqueSize : 53520367616
BackingObjectId :
Accessible : True


PS C:\> 53520367616/1024/1024/1024
49.8447265625


here the out put of disk size with difference of 8 GB. i ran this on my test env, when i run the same on prod many servers report with 0 or lesser than what it shows on the guest level. 

Reply
0 Kudos
LucD
Leadership
Leadership

Do you mean with "on the guest level" the disksize shown inside the guest OS?
And which type of guest OS is that?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos