The below script lists all datastores with less than 20% free space:
Connect-VIServer -Server vCenterName function CalcPercent { param( [parameter(Mandatory = $true)] [int]$InputNum1, [parameter(Mandatory = $true)] [int]$InputNum2) $InputNum1 / $InputNum2*100 } $datastores = Get-Datastore | Sort Name ForEach ($ds in $datastores) { if (($ds.Name -match "Shared") -or ($ds.Name -match "")) { $PercentFree = CalcPercent $ds.FreeSpaceMB $ds.CapacityMB $PercentFree = "{0:N2}" -f $PercentFree $ds | Add-Member -type NoteProperty -name PercentFree -value $PercentFree } } $datastores | where-object {$_.PercentFree -le 20} | Select Name,FreeSpaceGB,CapacityGB,PercentFree
![Share on Facebook Facebook](http://computercrashers.co.uk/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/facebook.png)
![Share on Twitter twitter](http://computercrashers.co.uk/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/twitter.png)
![Share on Google+ google_plus](http://computercrashers.co.uk/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/google_plus.png)
![Share on Linkedin linkedin](http://computercrashers.co.uk/wp-content/plugins/social-media-feather/synved-social/image/social/regular/48x48/linkedin.png)
![feather](http://computercrashers.co.uk/wp-content/plugins/social-media-feather/synved-social/image/icon.png)