Format results as HTML table w/ powershell

  • It's easy, but a reference that shows beginners how we take some data, perhaps performance or other data in a query and export it as an HTML report that can be viewed/ mailed/etc.

  • Steve Jones - SSC Editor (1/31/2014)


    It's easy, but a reference that shows beginners how we take some data, perhaps performance or other data in a query and export it as an HTML report that can be viewed/ mailed/etc.

    I missed this post. Got any takers yet, Steve?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • There is a really comprehensive cmdlet and tutorial that I use: http://gallery.technet.microsoft.com/scriptcenter/PowerShell-HTML-Notificatio-e1c5759d

    Seeing as I don't think that can be beat, I'd like to offer an alternative of SQL -> PowerShell -> Excel with sheets and formulas. I could put that together if you were interested.

  • Cody K (4/6/2014)


    There is a really comprehensive cmdlet and tutorial that I use: http://gallery.technet.microsoft.com/scriptcenter/PowerShell-HTML-Notificatio-e1c5759d

    Seeing as I don't think that can be beat, I'd like to offer an alternative of SQL -> PowerShell -> Excel with sheets and formulas. I could put that together if you were interested.

    Nice link. Just curious... how would you schedule such a thing to be emailed to a group of users at 8:AM every morning?

    t would also be awesome if you could show how you would do the same thing with the results of a query.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • No takers, and it would be nice to see this article.

    No offense, but your script isn't an article with explanation. It's not written as a short guide to lead people through the process.

  • I've written several PoSH scripts that access a SQL Server database and send alert emails, HTML formatted, using the Send-MailMessage cmdlet. The script can also sends a basic email to a pager/cell as an SMS message using the Net.Mail.SmtpClient object.

    I could put something together if interested.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Alan Smith

  • That's awesome but my question still remains. What are you good folks using to schedule the runs?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeff,

    It depends on what the job is doing. If the job requires to access server metadata, like service states, then I usually use a Scheduled Task and it generally works well enough and does not affect SQL Server CPU.

    If the job is more SQL Server oriented, then I have used a SQL Server Agent job and an operator with server credentials since Powershell 2.0 is not really supported natively in SQL Server 2008.

    Mostly it depends on the security setup on the server which way is the most practical.

    ~~~~~~~~~~~~~~~~~~~~~

    Alan Smith

  • Thanks, Alan.

    Correct me if I'm wrong... on the SQL Agent side of the house that you mentioned, if the PoSH code connects to the SQL server, wouldn't that would mean that you're actually consuming 2 connections? 1 by the agent job and 1 by the Posh code?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • So just to clarify, who is the taker? 😀

    Shawn Melton
    Twitter: @wsmelton
    Blog: wsmelton.github.com
    Github: wsmelton

  • It this hasn't been claimed yet, I'd like to take it. I'm working quite a bit with Powershell and formatted output right now, this would fit nicely...

  • Tracy, take it.

  • Steve Jones - SSC Editor (4/11/2014)


    Tracy, take it.

    Alrighty then, consider it taken...

  • Thanks, Tracy

Viewing 14 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic. Login to reply