Solved

modify script to display red value in stylesheet

Posted on 2015-01-13
2
65 Views
Last Modified: 2015-01-27
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
Comment
Question by:bibi92
2 Comments
 
LVL 39

Accepted Solution

by:
footech earned 500 total points
Comment Utility
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
 

Author Closing Comment

by:bibi92
Comment Utility
Thanks
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
This article will help you understand what HashTables are and how to use them in PowerShell.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now