How to Get HTML Cell in red depending on a condition while getting a output from Sharepoint powershell

In Below Script I am able to get "disksizerequired" number in red by below script but I want that whole Cell to be red.
Please let me know how to do it
# HTML code to format output
$b = "<style>"
$b = $b + "BODY{background-color:white;}"
$b = $b + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$b = $b + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"
$b = $b + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;}"
$b = $b + "</style>"
# Variable initializing to send mail
$TXTFile = "C:\Abhishek\test\test231.html"
$SMTPServer = "mapintmail.lab.com" 
$emailFrom = "[email protected]
$emailTo = "[email protected]
$subject = "Sharepoint Farms Content databases Report" 
$emailBody = "Dailyreport on Sharepoint Farms Content databases"
$encrypted ="01000000d08c9ddf0115d1118c7a00c04fc297eb0100000097606a1d1a7321488a23f2056c613f690000000002000000000003660000c000000010000000ebf48a9bd08c88a4de367597a1b86b390000000004800000a0000000100000006fa6c5ca0af8ad180e19cc6e5a42765e200000009a2551a74c5da425a1fa63705d1d7469fa0bb94409bf9a43ba951ee5c64d7ff614000000c9c659511fda53078b9f2e00f3b673349962affa"
$usser1 = "lab\abhi"
$usser2 = "labb\abhi"
$password = ConvertTo-SecureString -string $encrypted
$cred1 = new-object -typename System.Management.Automation.PSCredential -argumentlist $usser1,$password
$cred2 = new-object -typename System.Management.Automation.PSCredential -argumentlist $usser2,$password
# Creating PSSession and Loading Snapin
$s1 = New-PSSession -Authentication CredSSP -Credential $cred1 -ComputerName LROSHRPTL01
$s2 = New-PSSession -Authentication CredSSP -Credential $cred2 -ComputerName LROSHRPTL03
Invoke-Command -Session $s1 -ScriptBlock {Add-PSSnapin Microsoft.SharePoint.PowerShell}
$f1 = Invoke-Command -Session $s1 -ScriptBlock {Get-SPWebApplication | Get-SPContentDatabase}
$g1 = $f1 | Select-Object DisplayName,WebApplication,disksizerequired,CurrentSiteCount,WarningSiteCount,MaximumSiteCount | ConvertTo-Html -Fragment DisplayName,WebApplication,CurrentSiteCount,WarningSiteCount,MaximumSiteCount,@{label="disksizerequired";expression={
 if($_.disksizerequired -gt 1024*1204*1024)
 {"#font"+$_.disksizerequired+"font#"} 
 else
 {$_.disksizerequired}
$g1 = $g1 -replace "#font","<font color='red'>"
$g1 = $g1 -replace "font#","</font>"
Invoke-Command -Session $s2 -ScriptBlock {Add-PSSnapin Microsoft.SharePoint.PowerShell}
$f2 = Invoke-Command -Session $s2 -ScriptBlock {Get-SPWebApplication | Get-SPContentDatabase}
$g2 = $f2 | Select-Object DisplayName,WebApplication,disksizerequired,CurrentSiteCount,WarningSiteCount,MaximumSiteCount | ConvertTo-Html -Fragment DisplayName,WebApplication,CurrentSiteCount,WarningSiteCount,MaximumSiteCount,@{label="disksizerequired";expression={
 if($_.disksizerequired -gt 1024*1024*1024)
 {"#font"+$_.disksizerequired+"font#"} 
 else
 {$_.disksizerequired}
$g2 = $g2 -replace "#font","<font color='red'>"
$g2 = $g2 -replace "font#","</font>"
ConvertTo-HTML -head $b -Body "<h1>$(Get-Date) Sharepoint Farm Database Content DB Report</h1> <br /> <h2>SharePoint_Config_UAT2010 $g1 SharePoint_Config_Intranet2010  $g2</h2>" | Out-File C:\Abhishek\test\test231.html 
Invoke-Expression C:\Abhishek\test\test231.html
# Code to Send Mail
Send-MailMessage -SmtpServer $SMTPServer -From $emailFrom -To $emailTo -Subject $subject -Body $emailBody -Attachment $TXTFile

If I understand the script correctly, what it will be doing at the moment is setting the font colour to red, instead of the background colour. To do this, you'd normally have to sent the attribute on the <td bgcolor='red'>, rather than using <font
color='red'>, but you might try using a span instead.
$g2 = $g2 -replace "#font","<span style='background-color:red;'>"
$g2 = $g2 -replace "font#","</span>"
If this isn't what you're looking for (because there may be an untidy margin around the span, or something), you'll need to give the <td> a classname, and then change the css for that class within $b instead. Let me know if you prefer to try that.
OWA For SmartPhone

Similar Messages

  • Getting error while opening Excel document from SharePoint site

    Hello All,
    I am getting following error while opening Excel document from SharePoint site.
    This issue appears when we open Excel document from Windows>> Run using below mentioned command:
    Excel.exe "{File Name}"
    If once I go to Excel back stage and browse for the SharePoint location, then this problem disappears.
    I have a work around for this issue but main problem is that i do not have any work around when i need to open Exel document using Excel COM interop in C#.
    Thanks,
    Amit Bansal
    Amit Bansal http://www.oops4you.blogspot.com/

    Hi Amit Bansal,
    Thanks for posting in MSDN forum.
    This forum is for developers discussing developing issues involve Excel application.
    According to the description, you got an error when you open the document form SharePoint site.
    Based on my understanding, this issue maybe relative to the SharePoint, I would like move it to
    SharePoint 2013 - General Discussions and Questions forum.
    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.
    Thanks for your understanding.
    Regards & Fei
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to sent notification to a user depending on some condition?

    Hi All,
    I am working in iRecruitment Recruiter responsibility->iRecruitment Recruiter->Candidate
    I have an requirement that for a particular applicant if HR is taking Interview and he forgot to add feedback.Then a notification has been sent to him after a day.
    How to do it by workflow and Alert?
    Please Help.
    Thanks In Advance.
    Edited by: SHD on Jan 20, 2011 10:48 PM

    Perhaps you'll find this link useful. It gives a general idea of how you can create and adjust your custom renderer:
    http://www.senun.com/Left/Programming/Java_old/Examples_swing/JTableExamples4.html
    Hope it helps.
    Eugene

  • I am trying to update iTunes but get this box message comes up, "Network error occurred while attempting to read from the file: c:/windows/installer/itunes.msi" I have be told to uninstall all iTunes then reinstall, if I do this will I lose my Library

    Looking on the net to solve this problem, it says
    Removing and Reinstalling iTunes, QuickTime, and other software components for Windows XP
    I have save all my iTunes on a CD.
    If I uninstall iTunes, will I lose my iTunes library and video and apps and inturn will I lose this off my phone..
    I have tryed to update my iPhone firmware as they said there is a new update firmware, it would not install this and put my phone into recovery mode and I had to use iPhone recovery fix to get it out of recovery mode, my iPhone did a back-up before it tried to update the firmware.
    Any idea's are welcome

    Download the Windows Installer CleanUp utility from the following page (use one of the links under the "DOWNLOAD LOCATIONS" thingy on the Major Geeks page):
    http://majorgeeks.com/download.php?det=4459
    To install the utility, doubleclick the msicuu2.exe file you downloaded.
    Now run the utility ("Start > All Programs > Windows Install Clean Up"). In the list of programs that appears in CleanUp, select any iTunes entries and click "Remove", as per the following screenshot:
    Quit out of CleanUp, restart the PC and try another iTunes install. Does it go through properly this time?

  • Chart drilldown #LABEL# values gets HTML-ized in item assignments

    I have a single series pie chart which has LABEL values of '< 7 days', '7-30 days' and '> 30 days', generated from a query like this:
    select '',
    case
       when time_spent < 7 then '< 7 days'
       when time_spent > 30 then '> 30 days'
       else '7-30 days'
    end AS cat,
    count(*)
    from dataTo allow the user to drill down into the details of the chart, I created an Action Link set up as Link to Custom Target which takes me to an interactive report on another page. I set up Item 1 as an IR filter with the value set to *#LABEL#*.
    All this works fine, but when the IR report displays, the filter is getting HTML-ized.
    By that I mean:
    '< 7 days' get set to '&lt 7 days'
    '> 30 days' gets set to '&gt 30 days'
    This of course is then not returning any rows in the report as the values no longer match.
    Is there any way to make the value that gets set in the item show the actual < and > symbols and not the HTML versions of them? This is occurring to me in Apex 4.0 and 4.1
    Thanks,
    ~ John

    This has been resolved. For some reason the AnyChart template file in production was a different version. We copied this file from our development environment and now it works.

  • Exception while getting MarketData - in FBS

    I successfully deployed FBS on JDeveloper. However when i try running the app, i get the following msg while going for ControllerServlet. :
    oracle.otnsamples.ibfbs.admin.exception.AdminHelperException: Exception while getting MarketData : oracle.otnsamples.ibfbs.admin.exception.AdminHelperException: SQLException while getting Symbols list : java.sql.SQLException: ORA-00942: table or view does not exist
    Stack Trace :
    oracle.otnsamples.ibfbs.admin.exception.AdminHelperException: Exception while getting MarketData : oracle.otnsamples.ibfbs.admin.exception.AdminHelperException: SQLException while getting Symbols list : java.sql.SQLException: ORA-00942: table or view does not exist at oracle.otnsamples.ibfbs.admin.helper.StockSymbolHelper.getStockRatesandNews(StockSymbolHelper.java:369) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at oracle.otnsamples.ibfbs.control.RequestProcessor.processRequest(RequestProcessor.java:274) at oracle.otnsamples.ibfbs.control.ControllerServlet.process(ControllerServlet.java:121) at oracle.otnsamples.ibfbs.control.ControllerServlet.doGet(ControllerServlet.java:174) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65) at oracle.otnsamples.ibfbs.control.AccessControlFilter.doFilter(AccessControlFilter.java:217) at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:663) at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:330) at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:830) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:285) at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:126) at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186) at java.lang.Thread.run(Thread.java:534)
    Can anyone suggest a solution.

    Did you follow step no 1 in the setup list. ??
    http://www.oracle.com/technology/sample_code/tutorials/fbs/over/setup.htm
    and you should be using same db user account in the database configuration file.

  • Collab Subscription Emails: How to detect HTML enabled cell phone?

    We have found tremendous adoption success with using the "Subscribe Others" feature in collab. Naturally this concept rubs many folks the wrong way because often the end users don't know why they are getting these emails or what they are expected to do with them.
    To combat this problem I have been working on our email templates to include some brief FAQs at the bottom of the email that answer some of the basics: Why am I getting this email? How do I unsubscribe? etc
    There is still one issue that I am trying to resolve: Within the HTML template, is it possible to identify HTML enabled email readers?
    For example, I use a Blackberry 7250 which displays email in plaintext - when I get Collab emails they are LOADED with links to images and to the collab projects, and its frustrating to have to scroll through everything to find the meaningful stuff.
    My goal is to hide all "ugly link content" to those users that don't have HTML enabled phones - but I DO want to show it to those folks with the latest and greatest phones that can support it - such as the Blackberry Storm.
    Isolating browsers seems like it could be the way to go, but rather than coding on a per browser basis I was hoping to just be able to do some type of "if HTML enabled" check.
    Any suggestions?
    Also, if anyone is curious about how to adjust these templates feel free to ask here or email me at [email protected] and I can forward my basic manipulations.

    It turns out that there is a content type called "multipart/alternative" which can be used in cases like this.
    The content type allows you to essentially split up the content into a section for HTML and another for plain text.
    In looking at the notification templates, there are 2 for each "event". One for HTML and the other for plain text but I assume this is dependent upon the user Account Setting HTML/Plain Text and not fed into a higher level template which is set for multipart/alternative, although I have a help desk ticket setup for clarification on this issue.
    I played around with these content types and each time I crashed my notification service with a java.lang.NullPointerException.
    I'm closer to giving up on this after reading the following paragraph:
    "If email programs can recognize multipart/alternative content, they can probably also recognize HTML content.
    If they can't read HTML, they probably can't read multipart content either, which means you're going to run into the same problems with sending HTML to folks with email programs who can't understand it.
    For recipients who can read the HTML, you're sending along an extra large message with the text included for no reason." http://www.wilsonweb.com/wmt5/html-email-multi.htm
    Joel Collins wrote:
    1) you know users can select html or plain text notifications right? Its under my account.Right, but we want the email to determine it dynamically since our company uses Outlook we'd want them to get HTML when they are a desk, and plain text when they are on their cell phones.
    Joel Collins wrote:
    2) Would an easy solution be to just put the content of the email at the top and the links at the bottom?Definitely! I've already removed all of the images and some of the redundant links, and am trying to design a layout to add the remaining links either in a column right aligned or at the bottom.
    Joel Collins wrote:
    3) I think that detecting html or plain text reader may be hard / impossible.Yar, I think I'm 9/10 of the way to giving up on this:)

  • How do I get rid of a red square with a red circle around on my playlist on my iPhone 4S?

    How do I get rid of this red square with the red circle? It only shows on the right side of the song on my playlist and the song won't play. My playlist now skips 10/12songs before it plays another. When I checked iTunes on my computer there is nothing changed on the playlist. I downloaded the latest iTunes and synced the phone again but still nothing. I do not want to have to restore and do this all again. Help.

    Betty,
    My personal journey in learning CSS has been roughly:
    10% books
    http://oreilly.com/catalog/9780596527334/ (I began here)
    10% online resources
    http://htmldog.com/guides/cssbeginner/
    http://articles.sitepoint.com/article/html-css-beginners-guide#
    and many, many others
    30% deconstructing quality CSS templates
    http://www.projectseven.com/products/templates/index.htm (my personal favourites)
    50% trial and error (and lots of debugging and "what the...?" and "huh?" moments

  • HT1937 how do I get rid of the red dot on my iPhone, phone icon?

    How do I get rid of the red dot on my iPhone, phone icon ?

    If you did that already and looked at your recent calls and the red dot doesn't disappear then try rebooting the phone. Hold down the Sleep and the Home buttons until the Apple logo displays on the screen.

  • How do i get rid of the red dot on my voicemail which is deactivated

    how can i get rid of the red dot on the voice mail icon its driving me crazy
    please help

    Check to see if you have any old VM and listen/delete them.
    Try a reset... press the home and sleep/lock buttons until you see the Apple logo, ignoring the slider. Takes about 5-15 secs of button holding and you won't lose any data or settings.

  • How to get the cell info?

    You all know that, on our mobile we used to get the cell info ( Tower Name ). How to access that in our J2ME application?
    John

    Hello txflwr48! I regret the difficulties you've been having while activating your new phone. I'd love to help, but I recommend that we take our conversation to direct message instead of here in the public forum. If you have not yet gotten your device activated, please follow these steps to follow my handle (DionM_VZW) send me a direct message: http://vz.to/1gBiqkv
    DionM_VZW
    Follow us on Twitter www.twitter.com/vzwsupport

  • How do I get the cells to show up darker when printing my document

    When using Numbers, how do I get the cells to show up darker when printing my document?

    Are you asking about the cell background, as ivmedic has assumed, or about how to make the grid lines separating the cells darker?
    Select the table.
    Use the controls shown above this table to change:
    Stroke type from "Thin" to the solid line shown.
    Stroke thickness to 1 pt
    Stroke colour to a darker value (This is set to black, the rightmost cell in the top row of the Color Palette available fir this Color Well.)
    the controls are toward the right end of the Format Bar.
    Regards,
    Barry

  • In NUMBERS, on a iPad3, how do I get 1 cell to transfer to another cell on a different sheet?

    In NUMBERS, on a iPad3, how do I get 1 cell to transfer to another cell on a different sheet? Exm... Van 1, Auto Log, C7 to transfer over to Monthly report, April, C3

    Right-click on one of the other section headers. In the context menu that appears, make sure there is a checkmark in File Handling.

  • How do I get rid of the red and white compass rose used with the rotation tool...from the document? I am using a iMac and Macbook Pro OS Mavericks. CS6 no CC

    how do I get rid of the red and white compass rose used with the rotation tool...from the document? I am using a iMac and Macbook Pro OS Mavericks. CS6 no CC?
    any help appreciated...thank you! V

    I don’t think you can.

  • Hi, would you please help me to get red of hips of emails that I am receiving from this site? I want to delete my profile. How can I do it?

    Hi, would you please help me to get red of hips of emails that I am receiving from this site? I want to delete my profile. How can I do it?

    Read Frank Caggiano's User Tip here: Stopping emails from ASC

Maybe you are looking for

  • SM performance is very slow

    Dear Experts, We are facing an issue with SM tool's performance is very slow. It is taking minimum of 4 mins time to open a sm and when open/raise a CR, previously in OVSC it used to take only 20 seconds of time. It's not only about the raising of CR

  • How do I re-install previously purchased creative suite

    So my computer was stolen and I have a version of Creative Suite that I had previously purchased and only had installed on my desktop and laptop.  I just received a new laptop and need to download the product again.  I can't find it through my Adobe

  • Downgrading InDesign from CC 2014 to CC for addon compatibility

    I recently upgraded all my apps to the CC 2014 version but found that InDesign CC 2014 does not work with an important addon I need. Can I download and install InDesign CC alongside the latest version?

  • Multiple listings of artists are displayed on my iPod

    Help! I just downloaded the newest version of software onto my iPod and now I'm having problems with artists being listed multiple times when I look under "Artists" on my iPod. When I go into iTunes, the artist is only listed with their songs, and th

  • Deluged by error messages!

    I recently switched from my Blackberry to another smartphone and now my husband uses it.  At the AT&T store, it was re-set, new SIM card, etc.  No sign of my earlier ownership in settings, etc. Yet I am recivng about 100 network error messages: BEGIN