Hi,
I'm trying to populate an HTML table with the following but for some reason I'm not getting the DataStoreCluster name and I'm not able to filter out LUNS that have a capacity of 1 TB or greater and have less than 1 TB of free space.
$report = Get-Datastore | Where-Object {$_.Name -notMatch ("ESX|Datastore1") -and ($_.CapacityMB -ge "1000000") -and ($_.FreeSpaceMB -lt "1000000")} | %{
New-Object PSObject -Property @{
ClusterName = (Get-DatastoreCluster -Datastore $_ | Select -ExpandProperty Name)
Name = $_.name
Capacity = ($_.CapacityMB * 1MB)
Provisioned = ($_.ExtensionData.Summary.Capacity - $_.ExtensionData.Summary.FreeSpace +
$_.ExtensionData.Summary.Uncommitted)
Used = ($_.CapacityMB * 1MB - $_.FreeSpaceMB * 1MB)
FreeSpace = ($_.FreeSpaceMB * 1MB)
PercFree = [math]::Round(100 * $_.FreeSpaceMB/$_.CapacityMB,2)
}
} | Sort-Object -Property PercFree
$report | %{
writedata $_.ClusterName $_.Name $_.Capacity $_.Provisioned $_.Used $_.FreeSpace $_.PercFree
}
}
Thanks,