Hey all,
I have a report that outputs all our datastores and the % Free but the output is just all the datastores at random. I would LOVE if it would output in alpha order. Any ideas?
function UsedSpace
{
param($ds)
[math]::Round(($ds.CapacityMB - $ds.FreeSpaceMB)/1024,4)
}
function FreeSpace
{
param($ds)
[math]::Round($ds.FreeSpaceMB/1024,4)
}
function PercUsed
{
param($ds)
[math]::Round((100 * ($ds.CapacityMB - $ds.FreeSpaceMB) / $ds.CapacityMB),2)
}
$Datastores = Get-Datastore
$myCol = @()
ForEach ($Datastore in $Datastores)
{
$myObj = "" | Select-Object Datastore, PercUsed
$myObj.Datastore = $Datastore.Name
$myObj.PercUsed = PercUsed $Datastore
$myCol += $myObj
}
$myCol | Sort-Object PercFree | ConvertTo-Html –title "Datastore space " –body "<H2>Datastore space available.</H2>" -head "<link rel='stylesheet' href='style.css' type='text/css' />" | Out-File -Append $filelocation