Avatar of campbell1972
campbell1972
 asked on

Powershell and ConvertTo-HTML

Puzzled by another issue with different outputs when running a script from Powershell ISE compared to a standard shell.

I am performing a number of SQL checks and formatting the resultset as an HTML fragment:

$html1 = $dataset1.Tables .......... ConvertTo-HTML -AS Table -fragment -PreContent '<h2>SQL Configuration</h2>' | Out-String

These fragments are then associated with variables covering each block of tests:

$svrconfig = $html1, $html2
$memory = $html3,$html4

The main body of HTML is defined as a variable (a$) containing div blocks for each of the variables listed above:

<div id+""Server Configuration"" class=""tabcontent"">" + $memory +"</div>

When running the final convert under ISE, a complete HTML document is produced with the variables in the div blocks being correctly substituted with the relevant HTML.

However, when executed under a standard Powershell shell with administrative rights, the final HTML conversion does not see the div variables being populated:

ConvertTo-HTML -body $a | Out-File -append $SQLStatusReport

As usual, any pointers gratefully received!

JC
Powershell* ise

Avatar of undefined
Last Comment
campbell1972

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Chris Dent

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Chris Dent

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
campbell1972

ASKER
Thanks for the quick response on this Chris.

I'll try setting some breakpoints via VS and will post my success or otherwise.
campbell1972

ASKER
Thanks Chris

Switching to VS and making good use of breakpoints has done the trick! A bit of cutting and pasting to put everything in its proper place and it is now presenting correctly.

Top notch advice, much appreciated!
campbell1972

ASKER
Top notch advice!
Your help has saved me hundreds of hours of internet surfing.
fblack61