0

I have a SQL record set that I pulled from our internal project management software that has HTML tags in it. I would like to take this record set and create a HTML document with Powershell that follows the format of the tags. Is it possible to do this?

I tried this code:

$VersionNotes = Invoke-Sqlcmd -ServerInstance $svr -Database $database -Query $versionSQL 

$VersionNotes | Select-Object Name, ReleaseNotes | ConvertTo-Html |  Out-File c:\temp\htmltest.htm
Invoke-Expression C:\Temp\htmltest.htm

But it just returns the SQL results unformated.

1 Answer 1

1

Try with this ..

$VersionNotes = Invoke-Sqlcmd -ServerInstance $svr -Database $database -Query $versionSQL 

$Html = $VersionNotes | Select-Object Name, ReleaseNotes | ConvertTo-Html | Out-String 
[System.Reflection.Assembly]::LoadWithPartialName("System.web") | Out-Null
$Html = [System.Web.Httputility]::HtmlDecode($Html)

ConvertTo-HTML  -PostContent $Html | Out-File C:\Temp\htmltest.htm
Invoke-Expression C:\Temp\htmltest.htm

More details How to make SQL results to HTML document using PowerShell

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.