Chapter 33. Tips and tricks for creating reports

 

This chapter covers

  • Working with HTML fragments
  • Creating HTML style reports
  • Sending reports by email

There’s definitely a trick to creating reports with PowerShell. Remember that PowerShell isn’t at its best when it’s forced to work with text; objects are where it excels. The more you can build your reports from objects, letting PowerShell take care of turning those into the necessary text, the better off you’ll be.

33.1. What not to do

Let’s start this chapter with an example of what we think is poor report-generating technique. We see code like this more often than we’d like. Most of the time the IT pro doesn’t know any better and is perpetuating techniques from other languages such as VBScript. The following listing, which we devoutly hope you’ll never run yourself, is a common approach that you’ll see less-informed administrators take.

33.2. Working with HTML fragments and files

33.3. Sending email

33.4. Summary