HTML color in powershell

Hello ,
I want to change one line color in powershell only. but when i tried to change it , the changes are in all the lines , how can i tell him to change it only if the word "DOWN" is in the line.
i want the change come only if the word is in the concerned line.
$servers= @("server1","server2")
$date = Get-Date -Format "dd-MM-yyyy----HH-mm-s"
$file = new-item -Path "C:\Documents and Settings\test\Desktop\$($date).txt" -ItemType file | Out-Null
$file = "C:\Documents and Settings\test\Desktop\$($date).txt"
foreach ($server in $servers)
if ((Test-Connection -ComputerName $server -count 2 -Quiet)-eq $true)
Add-Content -Path $file -Value "The server $server is UP"
"The server $server is UP"
else
{ Add-Content -Path $file -Value "The server $server is DOWN"
write-host "The server $server is DOWN" -fore "red"
$ServersUp = Get-Content $file | select  @{ Name = 'Servers Up' ; Expression = { $_ } }| ConvertTo-Html -Fragment -As Table -PreContent "<h2>Servers Up / Down</h2>" |
Out-String
$ServersUp = $ServersUp.Replace('<tr><th>*</th></tr>','<tr><th>Servers state actually</th></tr>')
foreach ($data in $ServersUp )
{ if ($data -match 'DOWN')
$data.Replace("<tr>","<tr bgcolor=#FF0000>")

We can also use jQuery and just inject it at build time:
# collect data
$servers= @('omega','devws2','joesgrg''W8TEST')
$results=$servers |
ForEach-Object{
$props=@{
Computername=$_
IsAlive=$false
$props.IsAlive=Test-Connection -ComputerName $_ -count 1 -Quiet
New-Object PsObject -Property $props
# build HTML
$htmlsplat=@{
Head='<script src="./jquery-1.10.2.js"></script>'
PostContent='<script>$( "tr:contains(Offline)" ).css( "backgroundColor", "yellow" );</script>'
$htmlfile="$pwd\test.hta"
$results |
Select ComputerName, @{N='Status';E={if($_.IsAlive){'Online'}else{'Offline'}}} |
ConvertTo-Html @htmlsplat | Out-File $htmlfile
#display
&$htmlfile
It needs an HTA to prevent warnings about controls or you can place it on a web server and set the server as a trusted location.
Download the js file from the jQuery site so it is local to the report.
¯\_(ツ)_/¯

Similar Messages

  • How do I replace image color with an exact html color code?

    I simply want to change the color of a small pic to an existing html color code, 3399CC.  The pic is very simple, and only has one color.  In Photoshop CS4, I go to:  Image -> Adjustments -> Replace Color.  For the new replacement color, when I type in 3399CC, it doesn't give me that color - it gives some other shade of that color.  (I can tell because I use a program that tells me the exact html code a color is when I hover my mouse over it).  It seems the only way to really get the color you want is to adjust the sliders (hue, saturation, and lightness).  But it'd be practically impossible to play around with every increment of those sliders until I get the exact color code.  
    There's got to be a way to simply enter the html color code and have the pic changed to that color.  Does anyone have any idea?

    Turns key.  WhirrRRRrrrrRRRrrrr....  Nothing.  (I answered in the other thread)
    Perhaps I've had too much coffee today, because I just got a clear vision of Bart Simpson, at the board, chalk in hand...
    SRGB IS KING!!!  SRGB IS DEAD!!!  LONG LIVE SRGB!!!
    SRGB IS KING!!!  SRGB IS DEAD!!!  LONG LIVE SRGB!!!
    SRGB IS KING!!!  SRGB IS DEAD!!!  LONG LIVE SRGB!!!
    SRGB IS KING!!!  SRGB IS DEAD!!!  LONG LIVE SRGB!!!
    SRGB IS KING!!!  SRGB IS DEAD!!!  LONG LIVE SRGB!!!
    SRGB IS KING!!!  SRGB IS DEAD!!!  LONG LIVE SRGB!!!
    -Noel

  • How to set a HTML color to a control button

    How to set a fixed color to a disabled button?
    I have a boolean button which has 3 status: on, off and disabled. I don't like the 'grayed and disabled' option. I will use red for off, green for on, and white gray (foreground color) for the disabled status. The HTML color code is BDBDBD. I tried to send the hex number 'BDBDBD' to the button property node 'color[4]' but was told that I was wiring to the wrong type of terminal.
    Could any one post a sample code of how to construct the structure of 'color[4]' using a RRGGBB number?
    Thanks,
    Ryan

    What exectly do you want and do you see.
    If I run the code you have in LabVIEW 9.0, I get the following result after running.
    For convenience I have shown the second color array you set as color indicators:
    Note that you use grey as the colors for True and False
    Here I have set made the colors more distinct:
    Ton
    Message Edited by TCPlomp on 07-10-2009 08:00 AM
    Message Edited by TCPlomp on 07-10-2009 08:01 AM
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!
    Attachments:
    ButtonColor_FP.png ‏17 KB
    ButtonColorMoreColor_FP.png ‏18 KB

  • How to change the font and background color in PowerShell

    From your error messages to your output parameters, changing the colors of different PowerShell variables and outcomes is a straightforward and useful way to customize your PowerShell console. You can quickly identify ouputs, error messages, parameters and more with simple color cues – and when you're dealing with a longer script, being able to quickly identify anything is a huge help.In aguide on how to configure and customize your color settingsin PowerShell, Petri walks through each and every step, and even donates some of itsown custom PowerShell color themes scripts. (It should be noted that this only works for PowerShell console and not PowerShell ISE.) You can access your color configuration by entering:Powershell$host.privatedataThis will pull up a list of all your colors as they are currently set.Image credit:Jeff HicksNow...
    This topic first appeared in the Spiceworks Community

    Use a custom Renderer. This is the JTable tutorial:
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html

  • HTML Content in Powershell HTML Output

    How do I include HTML tags in the table output generated by the ConvertTo-HTML command?
    For example, if I had an array of objects like this:
    FriendlyName,URL
    Microsoft,www.microsoft.com
    Google,www.google.com
    Yahoo,www.yahoo.com
    How could I make my ConvertTo-Html output something like this:
    <a href="www.microsoft.com">Microsoft</a>
    <a href="www.google.com">Google</a>
    <a href="www.yahoo.com">Yahoo</a>
    I have already tried making another property on my objects (OutHTML) with a string of "<a href=" + [char]34 + $URL + [char]34 + ">" + $FriendlyName + "</a>"
    Unfortunately, ConvertTo-Html does its job too well and it converts all of my HTML tags to use &lt; and &gt; so that the < and > will display on the webpage!  Thanks for your help!

    Thank you, that looks like it does exactly what I need!  Can you tell me if I'm correctly understanding what's going on in their example?
    $pso = New-Object PSObject -Property @{
    SiteUrl = $spweb.url
    PageTitle= $PageTitle
    PageUrl = "<a href='$PagesUrl'>$PageTitle</a>"
    } | ConvertTo-Html
    Add-Type -AssemblyName System.Web
    [System.Web.HttpUtility]::HtmlDecode($pso) |
    Out-File \\myfolder\InventoryReports\$CurrentMonth.html
    At first, they generate the powershell object with the desired properties (including a property for the formatted hypertext output), which is then converted in place to HTML.  It then loads the .Net framework System.Web class so that they can access
    the HtmlDecode() method.  They pass the HTML'ified $pso to that method, which searches through $pso for any HTML special characters (the &gt, &lt, etc.) and replaces them with the actual characters, then writes the modified string out to a file.
     Thanks for your help!

  • Change HTML Color

    Hi,
    I am trying to change the html page color from flash - I use
    the "getURL" method - It works fine within GoLive but when I
    display it in any browser I get: "
    javascript:document.body.bgColor='#773707'" in the address
    bar and the color does not change - What am I doing wrong?
    Thank you for any help

    use the externalinterface class to call javascript
    functions.

  • Any ideas how to control the html color?

    I've never had to do this before- but I'm trying to change
    the background color of the html page that holds my master.swf on
    load of an external swf... I'm not even sure as to where to begin
    to look-- if anyone has any suggestions- that would be lovely...
    most of the google search results are just giving me flash 4
    tutorials on how to change a movie clips color... ughhh.
    Thanks!

    Powergroup,
    You may want to post a little bit more about your intended application.  I know a TCSC is a power electronic device used to vary the series impedance of power transmission lines by varying the delay angle of the thryistors in the device.  If the inputs for the delay angle for the TCSC need to be updated deterministicallyyou might want to look into using LabVIEW Real-Time Software and Hardware to control the inputs.
    However if project entails developing a feedback control scheme to vary the impedance of a transmission line using a TCSC based on a reference input you may be more interested in how LabVIEW would be able to develop the control scheme. I imagine you would want to take measurements to demonstrate the correctness of the TCSC controller based on this reference input which would also be a consideration.
    Please post a little more about your application as it may help determine how to go about controlling your TCSC.  Thanks.
    Bassett

  • Powershell, design manager, uploading html file not creating associated master page file

    I am uploading a xyz.html file through powershell for 2 site collections, when .html file is uploaded and published it automatically creates xyz.master file. It is working fine for not publishing sites collection only, for publishing site collection .html file
    is uploaded successfully but it is not creating associated .master file. If I close powershell console and run again it works successfully.
    another interesting thing I noticed that if I specify "spadmin" account which I used to install sharepoint as  site collection primary administrator, all works well, currently I am using "spsiteCollection" account for primary site collection
    administrator and I am having above mentioned issue.
    powershell script is also running with spadmin account.
    I have ensured .html is checked in and publish properly, If I manually unpublish and publish .html file it creates .mater file. What could be the issue?

    Hi,
    According to your post, my understanding is that you have an issue about upload html file to master page gallery.
    I have used the PowerShell contains in the codeplex to upload the files to master page gallery, it works without any issue.
    https://uploadmasterpages.codeplex.com/
    You can check your PowerShell with this article, or use this bat file to upload directly to check whether it works.
    Thanks,
    Jason
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Jason Guo
    TechNet Community Support

  • Syntax Coloring for PHP in HTML Files

    I'd like consistent syntax color throughout my documents,
    which can be CSS, HTML or PHP. However, when I write PHP code into
    anything but a PHP document, it comes out in a single, or
    dual-color format making it much less "pretty", and not nearly as
    easy to read. HTML has CFM and ASP color options, but not PHP (and
    I don't want to have to format the color twice in preferences
    anyhow). I've tried grouping .html files in with the PHP/MySQL
    color grouping in the DocumentTypes setting (Dreamweaver
    8/Configuration/DocumentTypes), which works, but results in a crash
    each time I do anything but look at a document.
    Anyone experience this behavior, or better yet, have a
    solution to make Dreamwever's syntax color consistent within
    itself?
    BWT, this refers to Dreamweaver 8.0.2, Mac OS X 10.4.7. And
    the rest of the Studio is installed as well.

    jasonkenison wrote:
    > I'd like consistent syntax color throughout my
    documents, which can be CSS,
    > HTML or PHP. However, when I write PHP code into
    anything but a PHP document,
    > it comes out in a single, or dual-color format making it
    much less "pretty",
    > and not nearly as easy to read.
    Follow this link (watch the wrap), and scroll down to Randy
    Edmunds' answer:
    http://groups.google.com/group/macromedia.dreamweaver/browse_thread/thread/a60b556f59869a8 6/666ff112459275ec?lnk=gst&q=php+html+color&rnum=2#666ff112459275ec
    He gives the details for Windows, but you should be able to
    find the
    correct file easily enough on a Mac.
    David Powers
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "Foundation PHP 5 for Flash" (friends of ED)
    http://foundationphp.com/

  • Powershell Excel Chart - change series colors

    I have a Powershell script that reads values from an Excel sheet and then creates a chart based on the values. The script works but I want to change the colors of the series in the bar chart. In VB (using an Excel macro) the code is as follows:
    ActiveChart.SeriesCollection(7).Select
    With Selection.Format.Fill
    .Visible = msoTrue
    .ForeColor.RGB = RGB(17, 17, 17)
    .Solid
    End With
    Based on what I read Powershell doesn't process RGB colors so I tried using one of the default colors:
    $wb.ActiveChart.SeriesCollection(5).Format.Fill.ForeColor = "black"
    Whatever variation on this I try seems to make no difference to the color of the bar chart series values. Is it even possible to change the colors with Powershell?

    Hi,
    Based on my research, the below code should be used to change chart forecolor, please give it a try:
    $chart.SeriesCollection(1).Points(1).Format.Fill.ForeColor.RGB = 255
    More details please go through the below link:
    http://learn-powershell.net/2012/12/24/powershell-and-excel-adding-a-chart-and-header-filter-to-a-report/
    Regards,
    Yan Li
    Regards, Yan Li

  • HTML Tag Colors

    Is there any way to specify which tags get which colors for HTML tags (and to use this within a cfm page)
    If CFEclipse, you could specify <table> tags get "green", <input> tags get "orange", etc, but I'm not finding this capability in CFBuilder.  It seems to be an all or nothing deal (unless there's a way to specify the "keywords" within HTML -> Editors -> HTML -> Colors in preferences as is in some of the other Editors in CFBuilder)

    So - like - "not fit for purpose" then?
    That's my take.  I talked with a CFB dev at CFUnited '09 about this issue and it didn't sound like adding any DW/CFE'sh colorization was on the radar at that time.
    If there's not already one, I'll submit a feature request at http://cfbugs.adobe.com

  • Powershell: How to colorize cells or entire row

    Hi, 
    I have a little question:
    Goal: Colorize cells or row only on certains values for multiple tables. 
    i.e. Table 1: colorize red all cells in column "xx" with values >10 ; Table 2: colorize green all cells in column "xx" with values <5  ecc
    Problem: 
    $1 = Get-WBSummary |Select-Object NumberOfVersions, CurrentOperationStatus, LastSuccessfulBackupTime, NextBackupTime, LastBackupResultDetailedHR, DetailedMessage | ConvertTo-Html -PreContent "table1</p>" -Fragment
    $2 = Get-WBSummary |Select-Object NumberOfVersions, CurrentOperationStatus, LastSuccessfulBackupTime, NextBackupTime, LastBackupResultDetailedHR, DetailedMessage | ConvertTo-Html -PreContent "<p>table2</p>" -Fragment
    $x = ConvertTo-HTML -Title "test" -Body "$1 $2"
    There is a way to find different data in different table and colorize cells or row?
    Thanks
    Andrea Gallazzi
    windowserver.it - blog:
    andreagx.blogspot.com
    This posting is provided AS IS with no warranties, and confers no rights.

    This requires knowing a lot about how HTML and PowerSHell work
    Start here:
    http://tech-comments.blogspot.com/2012/08/powershell-use-vbscript-to-color-table.html
    How to dynamically colr HTML generated by PowerShell.
    http://tech-comments.blogspot.com/2012/07/powershell-dynamically-color-posh.html
    ¯\_(ツ)_/¯

  • MicroSoft color matching not working...whatelse should we expect from MS...using IE

    http://www.scbadasscoffee.com/play.html
    NOTE using IE: "***" image is a bit fuzzy. The color around
    the small image is suppose to be the same as the background color
    of the page "CD9933". Same is true for the color about the little
    radio image. The color is set to "CD9933".
    NOTE USING ALL OTHER browsers such as Firefox, Safari, Opera:
    The "***" image is sharp and the background colors to the "***" and
    "radio" match perfectly with the background HTML color.
    Please explain to me how MS is screwing me up and if there is
    away around this?
    Thanks, --bill

    I would say the only thing screwing you is you. They look
    exactly the same
    to me in IE6 and FF1.5x.
    But the color around the radio is definitely off in both
    (#CD9038).
    For sure, IE and FF render colors the same....
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "bdaul" <[email protected]> wrote in message
    news:ea77uq$j18$[email protected]..
    >
    http://www.scbadasscoffee.com/play.html
    >
    > NOTE using IE: "***" image is a bit fuzzy. The color
    around the small
    > image
    > is suppose to be the same as the background color of the
    page "CD9933".
    > Same
    > is true for the color about the little radio image. The
    color is set to
    > "CD9933".
    >
    > NOTE USING ALL OTHER browsers such as Firefox, Safari,
    Opera: The "***"
    > image
    > is sharp and the background colors to the "***" and
    "radio" match
    > perfectly
    > with the background HTML color.
    >
    > Please explain to me how MS is screwing me up and if
    there is away around
    > this?
    >
    > Thanks, --bill
    >
    >

  • Setting background color in multi record block

    Hi all!
    I've a table with around 150 records of colors with html-color-names and rgb codes.
    I would like to have a sample item in my form 9.0.4 to display the color as a preview for
    each record in a multi-record block when querying the table.
    I would not like to create a visual attribute for each color. So display_item() is no choice.
    (except: somebody show me how to create va's with the japi)
    Somebody knows a way to accomplish this?
    Thanks in advance and regards
    Stauder

    Here's a solution which should work :
    1. Use a mirror item for the numeric item which has to
    be displayed
    using the format mask based on value in column1
    The data type of the mirror item : Char
    X and Y co-ordinates : Same as the item
    on which it is
    mirrored
    Size and Height : Same as the item
    on which it is
    mirrored
    2. On normal display, Mirror item is displayed
    3. When Mouse-Click or Pre-Text Item trigger on the
    Mirror Item :
    - Use the Go_Item ('Actual Numeric Item');
    This will bring up the Numeric Item and the Mirror
    item goes in hiding
    - A VWI trigger on Numeric Item should Then be :
    If ( :col1 = 'A' ) Then
    :Mirror_Item :=
    To_char(:NumericItem, ',999,999.99');
    Else
    :Mirror_Item :=
    To_char(:NumericItem, '99999999');
    End If;
    4. A key-Next-Item (On Numeric Item) or other trigger ??
    should then
    use Go_Item (:Mirror Item) to bring forward the
    formatted numeric item
    -- Shailender Mehta --

  • Legend color on Home page misleading

    In P-track Application while creating project the colors for Hot is RED, Watch is Yellow, No issues is Green,Complete is Black and Unknown is no color.
    But when same legend is applied on Home page No issues and 'Unknown' are displayed is green due to which there is mislead in Project milestone display?
    Is there any way to change the color codes ? If yes how to change the color codes ?
    Please advice

    Prasant,
    I'd recommend against changing the HTML color codes; those are used in a couple of places, and were chosen to ensure that text remained readable.
    So, your color codes should look like the following:
    Color Name - Color Code - Sprite X -Sprite Y
        RED       #e10         0            0
      GREEN       #0c0         0          -80
    YELLOW       #fd0         0          -40
      BLACK       #aaa         0         -120
       GRAY       #F2F2F2      0         -160You should see an appropriate colored dot in the Sprite column of the report when the offsets are correct.
    That said, it sounds like your status code color assignments may have gotten out of whack. To check these, go back to the administration page, and click through to Status Codes (first item on the left). Make sure the statuses are assigned the following colors:
    <li>Hot: RED
    <li>Watch: YELLOW
    <li>No Issues: GREEN
    <li>Complete: BLACK
    <li>Unknown: GRAY
    Hope that helps,
    -D.

Maybe you are looking for