Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 76
  • Last Modified:

modify script to display red value in stylesheet

Hello,

how to modify this script to display red, backups whose delta is greater than 0 ?


#Stylesheet for returning results

$style = '<style>'

$style = $style + 'BODY{background-color:peachpuff;}'

$style = $style + 'TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}'

$style = $style + 'TH{border-width: 1px;padding: 2px;border-style: solid;border-color: black;background-color:thistle;font-size:16}'

$style = $style+ 'TD{border-width: 1px;padding: 5px;border-style: solid;border-color: black;background-color:palegoldenrod;font-size:14}'

$style = $style + '</style>'



$Databases_Backups = invoke-sqlcmd @params -Query "Select ServerName,

    DatabaseName

    , case LastAbsoluteBackupDate

            when '1900-01-01 00:00:00' then 'Never Backed Up'

            else convert(varchar(20), LastAbsoluteBackupDate, 120)

            end as LastBackup

    , case LastAbsoluteBackupDate

            when '1900-01-01 00:00:00' then 'Never Backed Up'

            else convert(varchar,BackupDelta)

            end as BackupDelta

    from dbo.DatabaseBackups order by BackupDelta desc " | convertTo-Html -Head $style -Property ServerName, DatabaseName, LastBackup, BackupDelta | out-string;

Open in new window


Thanks

Regards
0
bibi92
Asked:
bibi92
1 Solution
 
footechCommented:
PowerShell doesn't do something like this well.
You either have to manually generate the HTML, or when possible take the output from ConvertTo-HTML and do string replace operations to modify the HTML so it includes the HTML code for the formatting you desire.

Do you know what the HTML would look like to give you the output you want?  Since I don't want to research HTML code, if you can give sample output (i.e. HTML source that shows 3 rows of output) that includes the formatting you want it would help.

You might also try the function I found at
http://community.spiceworks.com/scripts/show/2450-change-cell-color-in-html-table-with-powershell-set-cellcolor
0
 
bibi92Author Commented:
Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now