Script advice

This topic contains 4 replies, has 4 voices, and was last updated by Profile photo of MichaelKF MichaelKF 9 months, 3 weeks ago.

  • Author
    Posts
  • #35202
    Profile photo of Karl Forster
    Karl Forster
    Participant

    I have script that does a query of the load of our terminal servers every hour during business hours for capacity planning.
    At the moment the script emails out the details in the following format and we get an email every hour.

    ****** TSFarm ********

    HHG-TS518 36
    HHG-TS519 36
    HHG-TS520 37
    HHG-TS521 36
    HHG-TS522 36
    HHG-TS523 36
    HHG-TS524 36
    HHG-TS525 35
    HHG-TS526 35
    HHG-TS529 23

    I would like to change this to a single HTML report, but have it so that the HTML report shows us the stats per server but shows us the number based on every hour, something similar to this:
    ****** TSFarm ********
    Server 9am 10am 11am
    HHG-TS518 36 36
    HHG-TS519 36 36
    HHG-TS520 37 37
    HHG-TS521 36 36
    HHG-TS522 36 36
    HHG-TS523 36 36
    HHG-TS524 36 36
    HHG-TS525 35 35
    HHG-TS526 35 35
    HHG-TS529 23 23
    Is there a way to achieve this without getting into piping the results to a SQL database? In my mind the problem is that once the script ends the data is lost unless I store it somewhere.
    Any advice would be appreciated.
    Karl

  • #35204
    Profile photo of Dan Potter
    Dan Potter
    Participant

    Pull in the current html, build on it and replace it.

  • #35205
    Profile photo of Wilfredo Perez
    Wilfredo Perez
    Participant

    Check out the free ebook "Creating HTML Reports in PowerShell " under resources

  • #35207
    Profile photo of Karl Forster
    Karl Forster
    Participant

    I think my question may have cause come confusion

    let me clarify

    If I perform the query at 9am and it returns the following results
    server 9am
    HHG-TS518 36

    Then at 10am I perform the same query again

    server 9am 10am
    HHG-TS518 36 38

    Would it be best to store these in an CSV file and then build the HTML report from the CSV file. Every time the script closes the data would be lost from powershell so need some way to get the previous data.

    Karl

  • #35226
    Profile photo of MichaelKF
    MichaelKF
    Participant

    Hi Karl,

    I guess, the best practice would be to create objects ([pscustomobject]) and store it in a XML file on disk using Export-Clixml.

    Regards,
    Michael

You must be logged in to reply to this topic.