troubleshooting Question

Powershell and ConvertTo-HTML

Avatar of campbell1972
campbell1972 asked on
Powershell* ise
5 Comments2 Solutions289 ViewsLast Modified:
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
ASKER CERTIFIED SOLUTION
Chris Dent
PowerShell Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2010

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 2 Answers and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros