Welcome › Forums › General PowerShell Q&A › HTML Conditional formatting
This topic contains 2 replies, has 2 voices, and was last updated by
-
AuthorPosts
-
September 30, 2014 at 11:23 pm #19225
Function RDPStatus {
$Prop = [ordered]@{}
$ComputerName = Get-Content C:\computers.txt -ReadCount 0
$ErrorActionPreference = "Stop"
foreach ($computer in $ComputerName)
{
Try {$Prop.Computername = GWMI win32_operatingsystem -cn $computer | select-object -ExpandProperty CSName
$Network = GWMI -CN $computer -Class Win32_NetworkAdapterConfiguration -Filter 'ipenabled = "true"' | Select-Object -ExpandProperty IPAddress
$Prop.IPadddress = $Network -join ','
$Reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $computer)
$RegKey= $Reg.OpenSubKey("SYSTEM\\CurrentControlSet\\Control\\Terminal Server")
$RDP = $Regkey.GetValue("fDenyTSConnections")if ($RDP -eq 1)
{
$Prop.RDP = "Disabled"}
else
{
$Prop.RDP= "Enabled"
}$Bios = GWMI win32_bios -cn $computer | Select-Object -ExpandProperty SerialNumber
$Model= GWMI win32_computersystem -cn $computer | Select-Object -ExpandProperty Model
$Prop.BiosSlNos =$Bios
$Prop.Model = $ModelNew-Object PSObject -property $Prop
}
Catch{
Add-Content "$computer is not reachable" -path $env:USERPROFILE\Desktop\UnreachableHosts.txt
}
}
}
#HTML Color Code
#http://technet.microsoft.com/en-us/librProp/ff730936.aspx
$a = ""
$a = $a + "BODY{background-color:#DAA520;font-family:verdana;font-size:10pt;}"
$a = $a + "TABLE{border-width: 2px;border-style: solid;border-color:#000000;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: #000000;background-color:#7FFF00;}"
$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: #000000;background-color:#FFD700;}"
$a = $a + ""
RDPStatus | ConvertTo-HTML -head $a -body "RDP Status" |
Out-File $env:USERPROFILE\Desktop\RDPStatus.htm #HTML Output
Invoke-Item $env:USERPROFILE\Desktop\RDPStatus.htm
____________________________________________________
{
$Prop.RDP = "Disabled" —- Need red color in background cell}
else
{
$Prop.RDP= "Enabled"
}
_________________________________________________
Thanks in advance -
October 1, 2014 at 12:04 am #19226
Conditional cell formatting isn't easy with the native HTML cmdlets. Grab our free ebook, "Creating HTML Reports in PowerShell." It comes with an EnhancedHTML2 module that does this, and includes numerous examples.
-
October 1, 2014 at 3:13 am #19232
Thanks Don 🙂
-
AuthorPosts
The topic ‘HTML Conditional formatting’ is closed to new replies.