Solved

modify script to display red value in stylesheet

Posted on 2015-01-13
2
72 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 40

Accepted Solution

by:
footech earned 500 total points
ID: 40548152
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
ID: 40574638
Thanks
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

696 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