Function Get-Diskinfo {
Clear-Content "c:\Scripts\comps.txt"
Clear-Content "C:\Users\administrator.CONTOSO\Desktop\UnreachableHosts.txt"
[System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest().domains.DomainControllers.Name | Out-File "c:\Scripts\comps.txt"
$computername = Get-Content "c:\Scripts\comps.txt" -ReadCount 0
$ErrorActionPreference = "Stop"
foreach ($computer in $computername)
{
Try{
Get-WmiObject Win32_LogicalDisk -filter "DriveType=3" -computer $computer |
Select SystemName,DeviceID,@{Name="Size(GB)";
Expression={"{0:N1}" -f($_.size/1gb)}},@{Name="FreeSpace(GB)";
Expression={"{0:N1}" -f($_.freespace/1gb)}},@{Name="LOW SPACE";
Expression={"{0:N1}" -f($_.freespace / $_.size -lt .2)}}
}
Catch
{
Add-Content "$computer is not reachable" -path C:\Users\administrator.CONTOSO\Desktop\error.txt
}
}}
$a = ""
$a = $a + "BODY{background-color:#95B9C7;font-family:Calibri;font-size:10pt;}"
$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;background-color:thistle}"
$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:palegoldenrod}"
$a = $a + ""
Get-Diskinfo | ConvertTo-HTML -Head $a | out-file c:\Scripts\DCs.htm
Above code is working fine. Want to add Color Red when False becomes True on Lowspace.