by jmiller76 at 2012-10-31 12:54:21
I started to submit this to just Don as feedback via Concentrated Tech, but discussions are so much more productive. These are some of the thoughts I had after looking at the example and parts of the book. I will dig into the book more, I had only accidently realized that the November version had been published so I need to read more.by DonJ at 2012-11-01 13:25:42
I am looking to do a presentation at the DFW PowerShell User Group/NTPCUG PS SIG on general powershell reporting. I am planning to do a couple points on the console Format commands, out-gridview, Excel, and HTML. At my office I have been using a fair amount of output to Excel, but HTML is a very compelling alternative.
It was very convenient for me that this ebook has recently become available.
I was trying to get some people interested in the sample "EnhancedHTML Module Demo.ps1". I was showing them the resulting HTML as bait. It may be worth adding a footer to the resulting report that goes back to the Ebook page. I may be the only one that it would help, but it seemed like something worth sharing.
I saw a post on StackOverflow (http://stackoverflow.com/questions/4559233/technique-for-selectively-formatting-data-in-a-powershell-pipeline-and-output-as) where Jaykul suggested a technique using Linq to search the resulting XML output to insert contextual changes in the "Style" attribute. The sample showed highlighting text based on boundary conditions for TD innerText.
The big advantage with Excel for reporting some of my data is the easy graphs. But I found a post (http://blogs.technet.com/b/richard_macdonald/archive/2009/04/28/3231887.aspx) about building graphs with System.Windows.Forms.DataVisualization, and saving them to PNGs. Now an interactive graph would be even better, but I haven’t finished digging into the various options that present themselves with CSS and JavaScript. It looks completely doable, it just looks like a little bit of work would be needed.
When I am working on debugging my HTML reports, I use this block below.function Out-InternetExplorer {
Param($Text)
#From http://blogs.msdn.com/b/powershell/arch … shell.aspx
$oie = new-object -com internetexplorer.application
$oIE.navigate2("About:blank")
while ($oIE.busy) {
sleep -milliseconds 50
}
$oIE.visible=$true
If ($oIE.document.psbase.tostring() –eq “system.__comobjectâ€) {
$oIE.document.write([string]$text)
}
else {
$oIE.document.IHTMLDOcument2_write([string]$text)
}
}
You could add a footer very easily, using the -PostContent parameter of ConvertTo-EnhancedHTML.by jmiller76 at 2012-11-02 08:04:44
Thanks for the note!
Thanks Don, I’ll wire that in for the user group demo and next time I try to sell the idea internally.by DonJ at 2012-11-02 08:10:21
Do you have any thoughts on the functionality of contitional formatting of the table cell based on it’s data? Or anything baked into the Microsoft java classes for charting? With the charting, I think that the ability to filter a table and have the charting reflect the filter would be a good bell/whistle for management.
I probably won’t dig that deeply into it. I have a certain preference for elegance in stuff like this - once you start doing what you’re describing, you’re no longer "wrapping" the existing ConvertTo-HTML, you’re writing an all-new one. Which wouldn’t be a bad thing, but it isn’t on my short-term agenda. I mean, I’d rather see something like this:by jmiller76 at 2012-11-02 08:24:27
Get-Service | ConvertTo-FancyHTML -Property Name,@{n=‘Status’,e={$.Status};css={ if ($.Status -eq ‘Running’} { ‘Green’ } else { ‘Red’ }}
Where you’re using the same kind of syntax that Format-Table uses to specify that on a per-property basis. Much more efficient than spinning through already-generated HTML. Chucking in charts and stuff definitely goes outside what I’m personally interested in but more power to whoever wants to tackle it!
I understand the scope, it is certianly something that can jump from to a large project once pandora’s box opens up.
I like the idea of inlcuing the FT hashtable formatting. If I pursue this that long, I’ll certianly try that avenue first. It is much more intuitive. The finished XML parse was interesting in how they addressed the efficiency. Certianly if it can be defined at the property level that would be best.
For simplicity I will probably stop at the PNG based charting.
Thanks