How to fill color in a cell having particular string when using convertto-html

Hello Scripters,
I have downloaded AD health check script but I am wondering if the cell color be changed for a particular string. Like all the cells having text "Failed"..should be in red color.
Here is the script-
Function Getservicestatus($service, $server)
$st = Get-service -computername $server | where-object { $_.name -eq $service }
if($st)
{$servicestatus= $st.status}
else
{$servicestatus = "Not found"}
Return $servicestatus
$Forest = [system.directoryservices.activedirectory.Forest]::GetCurrentForest()
[string[]]$computername = $Forest.domains | ForEach-Object {$_.DomainControllers} | ForEach-Object {$_.Name}
#Section -1
$report= @()
foreach ($server in $computername){
$temp = "" | select server, pingstatus
if ( Test-Connection -ComputerName $server -Count 1 -ErrorAction SilentlyContinue ) {
$temp.pingstatus = "Pinging"
else {
$temp.pingstatus = "Not pinging"
$temp.server = $server
$report+=$temp
$b = $report | select server, pingstatus | ConvertTo-HTML -Fragment -As Table -PreContent "<h2>Server Availability</h2>" | Out-String
#Section - 2
$report = @()
foreach ($server in $computername){
$temp = "" | select server, KDC, NtFrs, DFSR, netlogon, w32Time
$temp.server = $server
$temp.KDC = Getservicestatus -service "KDC" -server $server
$temp.NtFrs = Getservicestatus -service "NtFrs" -server $server
$temp.DFSR = Getservicestatus -service "DFSR" -server $server
$temp.netlogon = Getservicestatus -service "netlogon" -server $server
$temp.w32Time = Getservicestatus -service "w32Time" -server $server
$report+=$temp
$b+= $REPORT | select server, KDC, NtFrs, DFSR, netlogon, w32Time | ConvertTo-HTML -Fragment -As Table -PreContent "<h2>Service Status</h2>" | Out-String
#Section - 3
add-type -AssemblyName microsoft.visualbasic
$strings = "microsoft.visualbasic.strings" -as [type]
$report = @()
foreach ($server in $computername){
$temp = "" | select server, Netlogon, Advertising, Connectivity, Replication
$temp.server = $server
$svt = dcdiag /test:netlogons /s:$server
$svt1 = dcdiag /test:Advertising /s:$server
$svt2 = dcdiag /test:connectivity /s:$server
$svt3 = dcdiag /test:Replications /s:$server
if($strings::instr($svt, "passed test NetLogons")){$temp.Netlogon = "Passed"}
else
{$temp.Netlogon = "Failed"}
if($strings::instr($svt1, "passed test Advertising")){$temp.Advertising = "Passed"}
else
{$temp.Advertising = "Failed"}
if($strings::instr($svt2, "passed test Connectivity")){$temp.Connectivity = "Passed"}
else
{$temp.Connectivity = "Failed"}
if($strings::instr($svt3, "passed test Replications")){$temp.Replication = "Passed"}
else
{$temp.Replication = "Failed"}
$report+=$temp
$b+= $REPORT | select server, Netlogon, Advertising, Connectivity, Replication | ConvertTo-HTML -Fragment -As Table -PreContent "<h2>DCDIAG Test</h2>" | Out-String
#Section - 4
$workfile = repadmin.exe /showrepl * /csv
$results = ConvertFrom-Csv -InputObject $workfile | where {$_.'Number of Failures' -ge 1}
#$results = $results | where {$_.'Number of Failures' -gt 1 }
if ($results -ne $null ) {
$results = $results | select "Source DSA", "Naming Context", "Destination DSA" ,"Number of Failures", "Last Failure Time", "Last Success Time", "Last Failure Status"
$b+= $results | select "Source DSA", "Naming Context", "Destination DSA" ,"Number of Failures", "Last Failure Time", "Last Success Time", "Last Failure Status" | ConvertTo-HTML -Fragment -As Table -PreContent "<h2>Replication Status</h2>" | Out-String
} else {
$results = "There were no Replication Errors"
$b+= $results | ConvertTo-HTML -Fragment -PreContent "<h2>Replication Status</h2>" | Out-String
$head = @'
<style>
body { background-color:#dddddd;
font-family:Tahoma;
font-size:12pt; }
td, th { border:1px Solid Black;
border-collapse:collapse; }
th { color:white;
background-color:DarkGoldenRod; }
table, tr, td, th { padding: 2px; margin: 0px }
table { margin-left:50px; }
</style>
$s = ConvertTo-HTML -head $head -PostContent $b -Body "<h1>Active Directory Checklist</h1>" | Out-string
$emailFrom = ""
$emailTo = ""
$smtpserver= ""
$smtp=new-object Net.Mail.SmtpClient($smtpServer)
$msg = new-object Net.Mail.MailMessage
$msg.From = $emailFrom
$msg.To.Add($emailTo)
$msg.IsBodyHTML = $true
$msg.subject="Active Directory Health Check Report From Dlhdc02"
$msg.Body = $s
$smtp.Send($msg)
Like in the Ping Status (section - 1), I'd like all the cell having text "Not Pinging" should be in RED color.
Also I am facing an issue in the (Section - 4). When the value of $Results is not null I am getting the desired output but when the value is null the text ""There were no Replication Errors""  is not getting displayed in
the HTML body. Instead it comes as "*32" (32 is the number of letters in the text).
Please help me in fixing this ....
BR
Himanshu
MCTS|MCSE|MCSA:Messaging|CCNA

Here are instructions on  ways to color cells based on content.
http://tech-comments.blogspot.com/2012/07/powershell-dynamically-color-posh.html
\_(ツ)_/

Similar Messages

  • How can I get audio to play from my TV when using hdmi cable?  Video looks great, just no sound.

    How can I get audio to play from my TV when using hdmi cable?  Video looks great, just no sound.
    I've tried plugging the hdmi into the TV directly and the receiver.
    I get video every time.  HBO to Go , Xfinity, ABC, Youtube, etc...
    just no audio.  Any suggestions? 
    I've tried starting the apps then plugging in the hdmi cable.
    I never tried this before I upgraded to IOS 5.

    Claudiamil-
    I had not tried it with mine since upgrading to iOS 5, so I just did.  I'm using a small Vizio HDTV.  I did not try YouTube, but did try several videos and musical numbers.  In all cases there was sound, including stereo when the source had it.
    I assume you are getting sound from the iPad when the adapter is not connected, so the volume is not turned down.  Dah*veed's suggestion to reset may be what you need.
    Fred

  • How do I connect a camera to my macbook pro when using the computer with an external monitor in clamshell mode?

    How do I connect a camera to the Macbook Pro when using the computer in clamshell mode with an exrternal monitor?

    same as it ever was
    do it like nothing is different.
    be sure to have an external trackpad keyboard or mouse as you will loose them on the computer once it is closed.

  • How can I specify SMTP Email Server userID and password when using Email VIs?

    How can I specify SMTP Email Server userID and password when using Email VIs included in Internet Toolkit?

    Hi,
    A similar question was posted on Discussion Forums soem time back. Please see the link below.
    http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=135&HOID=506500000008000000C7B00000&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0
    You would find the last post in the above thread quite useful where it has a link to OpenG code. I am also copying that link for your reference.
    http://www.openg.org/tiki/tiki-index.php?page=OpenG+Internet+Connectivity+Tools
    Please feel free to respond to this post with any questions/comments you may have.
    Regards,
    Ankita A.
    National Instruments

  • Please help. my address bar has vanished. i have no idea how to retrieve it, so can only access bookmarked sites when using firefox.

    please help. my address bar has vanished. i have no idea how to retrieve it, so can only access bookmarked sites when using firefox.

    Make sure that you do not run Firefox in Full Screen mode with all toolbars hidden.
    * Press F11 to toggle full screen mode (Firefox/File > Full Screen)
    If the menu bar is hidden then press the F10 key or hold down the Alt key, that should make the menu bar appear.
    Make sure that toolbars like the "Navigation Toolbar" and the "Bookmarks Toolbar" are visible: "View > Toolbars"
    * If items are missing then open the Customize window via "View > Toolbars > Customize" or via "Firefox > Options > Toolbar Layout" (Linux, Windows)
    * If a missing item is in the toolbar palette then drag it back from the Customize window on the toolbar
    * If you do not see an item on a toolbar and in the toolbar palette then click the "Restore Default Set" button to restore the default toolbar set up.
    See also:
    * http://kb.mozillazine.org/Toolbar_customization

  • How do I know if my I pad is secure when using the Internet.

    How do I know if my I pad is secure when using the Internet?

    Pretty much the same way you'd know with any other device. Are you using cellular data? It's pretty secure. Are you using WiFi? If so, is it public, unsecured wifi? Or private WiFi with a password? If you're doing any type of sensitive transactions, are you checking to make sure that the website is secure by checking to see that the address begins with https not just http? Are you making sure you're typing in address for banks and financial institutions rather than clicking on links in email?

  • Fill colors to ALV cells

    Hi All,
    How can I display multiple colors to different cells in an ALV ?.
    Please help..
    Thanks in advance,
    sudeep v d..

    Hi Sudeep,
    In the below mentioned link a topic Color of ALV output, columns, and cells has been mentioned in the section '4.17.3 Appearance of ALV Output'.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/db22242d-0701-0010-28a2-aeaa1fefd706
    Best regards,
    Suresh

  • How to fill colors into letters for example middle of letter O

    Hi
    I need to fill colors into letters like say O so I need to fill the empty part inside O with colors etc and so on with other letters too
    so what best method can be used to get a good clarity and perfection
    How can I select only that part
    Please help me in this
    Thanks

    function(){return A.apply(null,[this].concat($A(arguments)))}
    tokumaraditya wrote:
    what best method can be used to get a good clarity and perfection
    Just one thing to add:  Assuming your computer is up to it, do your master work at a higher pixel count than you will need in your final product  (e.g., 200% or 400%).
    -Noel

  • How to add colors to table cells

    Hi ALL,
    Does anyone have any idea of adding colors to table cells?For example i am displaying monthly chart in a table view i want to fill the cells with colors when columns are saturday and sunday.
    Thanks in advance

    Hi,
    I want to pass the colors at bean level.For example
    private DefaultTableViewModel createNewTable
                                      (DefaultTableViewModel model) {
            Vector data = createData();
            Vector colName = new Vector();
            /* Define column names */
            colName.addElement("1stColumn");
            colName.addElement("2ndColumn");
            colName.addElement("3rdColumn");
            model = new DefaultTableViewModel(data, colName);
            return model;
        private Vector createData() {
            Vector dataVec = new Vector();
            Vector retVector = new Vector();
            /* 1st entry */
            dataVec.addElement("Row 1, Column 1");
            dataVec.addElement("Row 1, Column 2");
            dataVec.addElement("Row 1, Column 3");
            retVector.addElement(dataVec);
            /* 2nd entry */
            dataVec = new Vector();
            dataVec.addElement("Row 2, Column 1");
            dataVec.addElement("Row 2, Column 2");
            dataVec.addElement("Row 2, Column 3");
            retVector.addElement(dataVec);
            /* more entries */
            return retVector;
    suppose I want to pass the color at Row2,Column1.Can anyone post the sample code ?
    its little urgent.Thanks in advance

  • How to fill a javascript array by a jsp array when the jsp is run

    Hi all,
    The problem i am facing is -- i want to use an javascript array in a function. The records are being fetched by jsp.
    How to fill the vaules in a javascript array, which are retrieved by a jsp array
    Please suggest
    Thanking You

    You can use the code below:
    <input type="button" value="Click Me" onclick="javascript:disp('<%= getString(str) %>')">
    <%!
    public String getString(String str[]){
    String arrElements="";
    for(int i=0;i<str.length;i++) {
    arrElements+=str[i]+",";
    return arrElements.substring(0,arrElements.length()-1);
    %>
    function disp(str) {
    arr = str.split(",");
    alert ("There are "+arr.length+" elements in the array");
    Hope this helps.

  • How should CMYK colors be built? Is it OK to use all three of CMY?

    This is a general question I'm posing here because I think it is the forum that is frequented by the largest number of people with real world print project management experience.
    The question is: in an ideal world, how should CMYK color be built? Lets assume I know the LAB values for several colors I want to reproduce accurately on an offset printing press. I can install the correct ICC Profile in my color management settings, input the LAB values, and let InDesign do the conversion to CMYK for me.
    However, I have been told by print professionals that, if at all possible, don't define a color swatch using all three CMY inks. Instead, use a maximum of two of CMY plus a K percentage. In other words, the ideal for printing CMYK screen tint mixes is to use percentages that use high GCR formulas - i.e. replace CMY with K where possible. This, so the the theory goes, helps to increase color stability on press.
    I guess in reality I have two questions: is that rule of thumb valid/useful? And if so...do I have any control over it in InDesign?

    That was my personal opinion guys as a contributor to this forum thread - it should be taken as an opinion only of course :) Using either or is obviously perfectly OK, I'm just a fan of using MDT to build and capture source images over Configuration Manager
    for a variety of reasons.
    My main point was that a build and capture Task Sequence can be used regardless of the requirement for a thin or thick image and that you can pause and resume a build and capture process to suit your requirements (and in my opinion MDT would be perfect for
    your situation). You should of course use Config Manager to deploy your Windows 8.1 custom image if you have that option.
    I've used capture media in the past and wouldn't recommend it. There's no technical reason, just my opinion :)
    Cheers
    Damon

  • How to force simple tags and null attributes to appear when using SQL/XML?

    Hello everybody:
    I'm developing a non-schema based XMLType view.
    When the XML document is generated, i noticed two things I need to manage in order to achieve the desired result:
    1. Oracle generates a <tag></tag> pair for each XMLELEMENT defined; in my case, some tags need to appear as <tag/>... how do I do? Is it possible when using schema based XMLType views? Is it possible while using a non-schema approach?
    2. When using XMLATTRIBUTE('' AS "attribute") or XMLATTRIBUTE(NULL AS "attribute"), no one attribute with label "attribute" and null value appears at the output; how do I force to Oracle DB to render those attributes which are with no values (needed to render those attributes as another parsing code will await for all the items)?
    3. Some tip about how to route the output to an XML text disk file will be appreciated.
    Thanks in advance.
    Edited by: Enyix on 26/02/2012 11:21 PM
    Edited by: Enyix on 26/02/2012 11:22 PM

    Hello odie_63, thanks for your reply:
    Reasons why needed single tags are these two next: Needed to generate a single XML file from 50,000,000 rows, where the XML ouput matches not only row data but another default values for another elements and attributes (not from database but using strings and types with default values); by using start and end tag, the generated file is as much twice bigger than using single tags; second, needed a very precise presentation for all the document.
    For generating that document, currently focus is based on using a batch process relying on Spring Batch with using a single JDBC query where a join happens between two tables. From my point of view, that approach uses: database resources, network resources, disk resources, and processing resources, including the price of making the join, sending to network, creating objects, validating, and making the file (Expending too much time generating that XML file). That processs currently is in development.
    I think possibly another approach is delegating the complete generation of that file to the database using its XML capabilities. My current approach following your recomendations is to generate a clob where I will put all the XML and putting it into a table. It leads me to another issues: Considering limitations on memory, processing and disk space, needed to append a single row-as-xml into the clob as soon as possible, and putting the clob inside the field as soon as possible, or putting the clob inside the field, and appending into it as the data is generated; so How do I manage the process in order to achieve that goals?. Seen these issues aren't related to my original question, so I'll open a new post. Any help will be apreciated.
    Thanks again in advance.

  • How to execute a jar file which has an applet, without using a html file ?

    I have a jar file which contains a set of class files. iam able to execute the jar file by using this html code
    <html>
    <applet code="file.class" archive="file.jar" width="500" height="300">
    <param name="name" value="value">
    </applet>
    </html>
    I want to know how to execute this class file without using the html tags.
    pls help me out in this.
    Anki

    Hi,
    You can make an executable jar file such that when you double click on that it starts running. Just follow the steps.
    1. Open a notepad and write the following
    Main-Class: XXXXXXXX
    XXXXXXX means Your Main Class name. Don't forget to press Enter after you write your class name.
    2. Save the file as Mani.mf
    3. In the commant prompt ( your directory ) type following lines.
    jar cmf Mani.mf Demo.jar *.*
    4. This will make a jar file which is executable jar file
    Hope this will help you.
    Deepak

  • How can I save a reply email to drafts folder when using hotmail on my ipad2 with safari ??

    It appears that the iPad mail app cannot push drafts so I can access them on a pc.     If there is a way to do this, I would like to know
    If the above is not possible, I'd like to know how to save a reply email to the drafts folder when accessing hotmail on my iPad from safari.   I can't seem to find a button on the hotmail pag, or any help instructions anywhere.     I hav done this for years using a pc with Firefox or explorer with no problem.  This has to be so easy that it will seem like I asked q stupid Ustinov when I get the answer!

    I am still waiting for an answer.    If you don't know the answer, but know who to ask or where to look to find an answer, I'd really appreciate it.

  • How can I keep my signature on the left side when using rtl on mail application

    I'm writing in Hebrew & English on apple Mail application on OS X /mountain Lion.
    When I'm starting to write a mail in HEBREW it's automatically move the signature to the right side which I don't like it because my signature is in English (My Hebrew is a why better from my English ; )
    How can I keep the signature on the left side as default?
    Hope to get your support in this issue.
    Thanks in advance,
    Joni.

    Joni11 wrote:
    How could i do this?
    Sorry, I don't know.  But have you already tried selecting your sig and using the usual alignment tools?  It seems to work for me when used in the new message pane.

Maybe you are looking for

  • Error  ORABPEL-05250

    Getting given error during deployment. Build is getting successful. *ORABPEL-05250[[ Error deploying BPEL suitcase.* error while attempting to deploy the BPEL component file "/oracle/product/Middleware/user_projects/domains/base_domain/deployed-compo

  • Duplicate material code

    Hi MM Experts, Let me know how to avoid duplicity of material based on material descrition? I want that whenever new material is created we should have tool to check based on the material description to avoid duplicity. Thnx AC

  • 16GB SODIMM anyone interested in pushing TOSHIBA together to update BIOS

    Hi, Anyone interested to convice Toshiba to update the  BIOS Memory Reference Code routine to recognize the new 16GByte SODIMM modules released by the memory company I´m Intelligent for the differnet product lines including laptop Satellite? We could

  • HP Simplepass 2012 need to uninstall and reinstall

    The program will no longer ask for finger swipe. always asks for windows master password. Does not even ask for that on some websites such as facebook. Also will not log on to windows with finger swpe. What is the best way to uninstall and the instal

  • ACCOUNT NOT WORKING

    Hello , when i login my account everything is grey , even ECHO sound sercive is offline (evrything offline) , when my friend log in his accout evrything is working . What should i do ? can anyone say skipe support @mail or smth ?