I am trying to generate an HTML report that will make a line red if a threshold has been reached. Here is what I have and I am not sure of how to evaluate each line for a value of say (FreespaceGB -le 60.00) then make line red.
$File = "Default.htm"
# Check to see if the file exists
if (Test-Path $File)
{
Remove-Item $File
}
$Collection = @()
Get-Cluster | ForEach-Object {
$Cluster = $_
$Cluster | Get-VMHost | ForEach-Object {
$VMHost = $_
$VMHost | Get-DataStore | Where-Object { $_.Name -notlike "*local*"} | ForEach-Object {
$out = "" | Select-Object Cluster, DSName, FreespaceGB, CapacityGB, PercentFree
$out.Cluster = $Cluster.Name
$out.DSName = $_.Name
$out.FreespaceGB = $($_.FreespaceMB / 1024).tostring("F02")
$out.CapacityGB = $($_.CapacityMB / 1024).tostring("F02")
$out.PercentFree = (($_.FreespaceMB) / ($_.CapacityMB) * 100).tostring("F02") + "%"
$Collection += $out
}
}
}
$a = "<style>"
$a = $a + "BODY{background-color:white;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;}"
$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;}"
$a = $a + "</style>"
$Collection | Sort-Object Cluster, DSName -Unique | ConvertTo-HTML -head $a | Out-File $File