Can I do this better?

Welcome Forums General PowerShell Q&A Can I do this better?

This topic contains 2 replies, has 2 voices, and was last updated by

4 years, 12 months ago.

  • Author
  • #15581

    Topics: 18
    Replies: 23
    Points: 0
    Rank: Member


    Back again 're-purposing' (or as I like to call it 'screwing it up for my own purposes') another script in my quest for learning and world domination.

    In essence I have a css style assigned to $Style for use with ConvertTo-HTML. The script goes away and collects some info which it puts into an variable called $Var. A separate variable called $Table is created and the following create a $Body variable which is used to as body text for an email.
    $Body = $Var | Select $Table | ConvertTo-HTML -head $Style

    What I want to do is add some text above the table and format with the predefined $Style.
    I have tried this:
    $BodyTable = $ItaniumUpdates | Select $Table | ConvertTo-HTML -head $Style
    $Body = "Some text here." + $BodyTable

    but this doesn't format the "Some text here." according to style

    How do I add the text to the email before the table and still format it?

  • #15582

    Topics: 18
    Replies: 23
    Points: 0
    Rank: Member

    Yes, use the -body parameter
    $Body = $Var | Select $Table | ConvertTo-HTML -head $Style -boby"Some text here."
    Love it that I've answered my own question!!!

  • #15586

    Topics: 13
    Replies: 4872
    Points: 1,811
    Helping HandTeam Member
    Rank: Community Hero

    If you wrap your text in an HTML element, like a div, you can apply a class to it and then format that class in your css.

The topic ‘Can I do this better?’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort