$VC = Connect-VIServer (Read-Host "VC Server") $output = Read-Host "Output file" function UsedSpace { param($ds) [math]::Round(($ds.CapacityMB - $ds.FreeSpaceMB)/1024,2) } function FreeSpace { param($ds) [math]::Round($ds.FreeSpaceMB/1024,2) } function PercFree { param($ds) [math]::Round((100 * $ds.FreeSpaceMB / $ds.CapacityMB),0) } $Datastores = Get-Datastore $myCol = @() ForEach ($Datastore in $Datastores) { $myObj = "" | Select-Object Datastore, UsedGB, FreeGB, PercFree $myObj.Datastore = $Datastore.Name $myObj.UsedGB = UsedSpace $Datastore $myObj.FreeGB = FreeSpace $Datastore $myObj.PercFree = PercFree $Datastore $myCol += $myObj } Disconnect-VIServer -Confirm:$False $myCol | Sort-Object PercFree | ConvertTo-Html | Out-File $output Invoke-Item $output