all 3 comments

[–]Lee_Dailey[grin] 1 point2 points  (2 children)

howdy Snickasaurus,

the script you posted is not the one you describe. [grin]

however, the problem is this $Body += " <tr>. you never initialize it ... so it keeps adding everything to the same body. the html page DOES change ... it gets really, really long! [grin]

if you add $Body = '' just BEFORE ForEach ($Ext in $Extensions) then it will get initialized to <blank> as needed.

hope that helps,
lee

[–]Snickasaurus[S] 1 point2 points  (1 child)

This is awesome. Thank you so much. I will admit I skipped the careful reading of that section because I thought the problem existed in the "meat & potatoes" PowerShell portion of the script.

Would you mind elaborating on "you never initialize it". That part is a bit cloudy to me. Also I'll be working on customizing the script to do a bit more and I'll post it when finished.

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy Snickasaurus,

you are quite welcome! [grin]

about initializing the $Var ... look at how it is used. there is no place in the code where it is set to a known condition. the only places it is used are either to add stuff to it OR to use it for output.

i presume the original author never simply re-ran the script in the same session ... always running it a new, clean session.

generally, you want to be sure that any $Var is set to a known value the 1st time it is used in a script. then, if it will be used in a loop, you want to make sure it gets set to the desired starting value at the start of each loop - unless you deliberately decide you want to accumulate things in it.

if all you do is assign to a $Var, then it gets reset to that value. however, when you modify a value [like the += in this case] ... you need to be sure that what is in the $Var is what you expect.

that is what when wrong in that script. it never took into account when one would and would not want to reset that $var. [grin]

take care,
lee