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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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!
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!
ASKER
Top notch advice!
ASKER
I'll try setting some breakpoints via VS and will post my success or otherwise.