Guys,
I'm faitly new to Powershell, is it possible to write a script tht will find any virtual disks and datastores that are are over 90% full? I would also like to export the results to an excel file.
Thanks.
For a 90% threshold you leave the value on 0.1.
I calculate the free space as a percentage, so if the freespace is less than or equal to 0.1 there is 10% or less free space available.
Hope that makes sense.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try this http://www.robware.net/ RVTools. I have been using it, it works good.
Try the following.
Note that the guests need to have the VMware Tools to be able to provide the info.
# Datastores
$dsThreshold = 0.1 Get-Datastore | where {$_.FreeSpaceMB/$_.CapacityMB -lt $dsThreshold} | `
Select Name,@{N="Free";E={"{0:p1}" -f ($_.FreeSpaceMB/$_.CapacityMB)}} # Guest disks
$hdThreshold = 0.1 foreach($vm in (Get-VM | where{$_.Guest.State -eq "running"} | Get-VMGuest)){ $vm.Disks | where {$_.FreeSpace/$_.Capacity -le $hdThreshold} | `
Select @{N="VM";E={$vm.VmName}},Path,@{N="Free";E={"{0:p1}"-f ($_.FreeSpace/$_.Capacity)}} }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
Thanks for the quick response. Is the variable dsThreshold where I specify my threshold? If I'm looking for any datastores above 90% capacity do I set
$dsThreshold = 90 (or would it be .9).
Sorry for all the stupid questions I'm new to powershell.
For a 90% threshold you leave the value on 0.1.
I calculate the free space as a percentage, so if the freespace is less than or equal to 0.1 there is 10% or less free space available.
Hope that makes sense.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference