Get-Datacenter -Name “xxx Datacenter” | Get-Datastore | Select-Object @{Label=”DataStore Name”;Expression={$_.Name}},@{Label=”GB Left”;Expression={[Math]::Round($_.FreeSpaceMB/1024,2)}},@{Label=”Capacity GB”;Expression={[Math]::Round($_.CapacityMB/1024,2)}},@{Label=”Free %”;Expression={[Math]::Round($_.FreeSpaceMB/$_.CapacityMB,3)*100}},@{Label=”New VMs”;Expression={[Math]::Floor(“{0:0.00;’0′}” -f (($_.FreeSpaceMB – 30000)/20480)) }} | ConvertTo-Html -Head $head -Body $header | Out-File “d:\bbb.html”
“{0:0.00;’0′}” -f (($_.FreeSpaceMB – 30000)/20480) -> will put 0 when the value will be negative, if positive if will leave the value like it is.
More about formatting:
http://msdn.microsoft.com/en-us/library/0c899ak8%28v=vs.71%29.aspx