VMware Cloud Community
Nithy07cs055
Hot Shot
Hot Shot

to get infrmation on Free space on C Drive for all VM's

Hi All

I used power CLI to get the hard disk information for all VM, but please let me know i can retriev the C drive free space on all VM's using a cmdlet.

Thanks and Regards, Nithyanathan R Please follow my page and Blog for more updates. Blog : https://communities.vmware.com/blogs/Nithyanathan Twitter @Nithy55 Facebook Vmware page : https://www.facebook.com/Virtualizationworld
0 Kudos
4 Replies
LucD
Leadership
Leadership

Do you have the VMware Tools installed on all your VMs ?

If yes, you can use the Get-VMGuest cmdlet, and in the returned object under the Disks property you should find the information.


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

0 Kudos
Nithy07cs055
Hot Shot
Hot Shot

this command only gives OS and IP information , but i need the free space available in all VM at onc

Thanks and Regards, Nithyanathan R Please follow my page and Blog for more updates. Blog : https://communities.vmware.com/blogs/Nithyanathan Twitter @Nithy55 Facebook Vmware page : https://www.facebook.com/Virtualizationworld
0 Kudos
LucD
Leadership
Leadership

Did you check the Disks property ?

Get-VMGuest | Select -ExpandProperty Disks


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

0 Kudos
Borja_Mari
Virtuoso
Virtuoso

Hello,

this code will do the trick (The virtual machines must be powered on and with vmware tools ok and installed)

Smiley Wink

ForEach ($VM in Get-VM | where-object {($_.powerstate -ne "PoweredOff") -and ($_.Extensiondata.Guest.ToolsStatus -Match ".*Ok.*")}){

ForEach ($Drive in $VM.Extensiondata.Guest.Disk) {

$Path = $Drive.DiskPath

#Calculations 

$Freespace = [math]::Round($Drive.FreeSpace / 1MB)

$Capacity = [math]::Round($Drive.Capacity/ 1MB)

$SpaceOverview = "$Freespace" + "/" + "$capacity" 

$PercentFree = [math]::Round(($FreeSpace)/ ($Capacity) * 100) 

$Output = $Output + "Vm: " + $VM.Name + "`n"

$Output = $Output + "Disk: " + $Path + "`n"

$OutPut = $Output + "Free(MB): " + $Freespace + "`n"

$Output = $Output + "Free(%): " + $PercentFree + "`n"  


} # End ForEach ($Drive in in $VM.Extensiondata.Guest.Disk)

} # End ForEach ($VM in Get-VM)

$Output

Remember to use the Connect-VIServer cmdlet before

Taken from here:

Report VM's Guest disks with less than 20% free space using powercli

Best regards,

Pablo

------------------------------------------------------------------------------------------------- PLEASE CONSIDER AWARDING any HELPFUL or CORRECT reply. Thanks!! Por favor CONSIDERA PREMIAR cualquier respuesta ÚTIL o CORRECTA . ¡¡Muchas gracias!! VCP3, VCP4, VCP5-DCV (VCP550), vExpert 2010, 2014 BLOG: http://communities.vmware.com/blogs/VirtuallyAnITNoob
0 Kudos