Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Colorful HTML rows

$
0
0

Hi guys,

I have following script that parse dblog file and creates HTML table. One of the column name is circularlogging. What i want is to make red circularlogging columns that have "false" value. Here is my script:

$DBParsing = get-content "C:\scripts\DBLog.log" |  ?{$_ -match "(.*): (.*): (.*): (.*): (.*): (.*): (.*): (.*): (.*)"} | select @{n="ServerName";e={$matches[1]}},@{n="DBName";e={$matches[2]}},@{n="CircularLogging";e={$matches[3]}},@{n="MBXCount";e={$matches[4]}},@{n="DBSize";e={$matches[5]}},@{n="WhiteSpace";e={$matches[6]}},@{n="DB_Disk_Free_Space";e={$matches[7]}},@{n="LOG_Disk_Free_Space";e={$matches[8]}},@{n="LastBackup";e={$matches[9]}} | ConvertTo-Html
$DBParsingHTMLArray +=$DBParsing
foreach ($DBArrayItem in $DBParsingHTMLArray)
{
$bgBackup = $null
$DatabaseTable += "<tr>"
if ($DBArrayItem.CircularLogging -match "False")
{
$bgBackup="red"
$DatabaseTable += "<td bgcolor=""$bgBackup"">$($DBArrayItem.CircularLogging)</td>"
}
else
{
$bgBackup="green"
$DatabaseTable += "<td bgcolor=""$bgBackup"">$($DBArrayItem.CircularLogging)</td>"
}
$DatabaseTable += "</tr>"
}
$Head = $a + "<table width=100%> $($DBParsingHTMLArray)" 
$HTML = $Head + "</table></html>"
$html | Out-File "C:\Scripts\ExcHtml.html"

With 

$DBParsingHTMLArray +=$DBParsing

command i just add dbparsing results to htmlarray variable. And then checks for circularlogging items.

But it has no affect, any idea would be appricated.

Here is an example dblog output.

Axxxxxxx : MailboxDatabase_2GB : False : 92 : 192.1GB : 63.88GB : 288,60 : 288,60 : 06.07.2013 21:04:51
Axxxxxxy : MailboxDatabase_1GB : False : 88 : 132GB : 32.65GB : 288,60 : 288,60 : 07.07.2013 21:04:01

and here is the HTML output example. Please note that there is no problem while creating HTML report.

Thanks in advance.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>