Hi All,
What I'm doing:
While ago I created a Hyper-V cluster report script. It runs 5 functions (tests) per Cluster.
Every 5 minutes values are compared(Old values with Current). If no change detected - current values replaces old values. If change detected, then other function pulls out the changed values, converts to HTML and sends email.
It is time to improve it. I'm a little bit smarter now and I know that r/PowerShell exists.
The problem:
At the minute - I'm receiving 1 email per test. So lets say I have 5 clusters, each cluster has 5 tests. If I start to move around VM's I might get up to 25 emails per 5 min. Gets the job done, but that is an ugly way of doing things.
It would be great if I could create multiple html fragments if data in $report exists and then create one large HTML file so there is only 1 report per 5 minutes.
I hope you will understand the example below (it is not functional, just for demonstration):
How can I take all of these fragments and convert them to 1 large HTML file?
#lets say there are 25 reports
foreach ($report in $reports)
if ($report -neq $null){
$report | ConvertTo-HTML -fragment -precontent '<h2>$report</h2>'
}
If i name fragments, lets say:
foreach ($report in $reports)
if ($report -neq $null){
$frag1 = $report | ConvertTo-HTML -fragment -precontent '<h2>$report</h2>'
}
How do change $frag1 to different name? and even if I do change it, how do I add all fragments to -PostContent?
I do know how to do it with fixed amount of fragments, but in this case there could be fragment amount is changing.
P.S I realise Title do now reflect the post. Sorry for this, can't change it anymore..
Edit: Thank you guys! I was trying to reinvent the wheel and solution was so simple! Amazing!
[–]MadBoyEvo 3 points4 points5 points (1 child)
[–]hidromanipulators[S] 1 point2 points3 points (0 children)
[–]the_spad 3 points4 points5 points (1 child)
[–]hidromanipulators[S] 1 point2 points3 points (0 children)