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.
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
this command only gives OS and IP information , but i need the free space available in all VM at onc
Did you check the Disks property ?
Get-VMGuest | Select -ExpandProperty Disks
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello,
this code will do the trick (The virtual machines must be powered on and with vmware tools ok and installed)
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