Turns a PowerShell .ps1 into a self-contained HTML file with VS Code Dark+-style syntax highlighting. Useful for sharing script source in a browser, attaching readable HTML to docs, or publishing a pretty copy next to a usage page.
| Name | Required | Default | Purpose |
|---|---|---|---|
Path | Yes | — | Source script path (.ps1 or other text PowerShell file) |
OutFile | No | Same folder/name as Path with .html | Destination HTML path |
Title | No | Source file name | <title> and heading text |
LineNumbers | No | $true | Show line-number gutter; pass -LineNumbers:$false to hide |
# Basic: write Script.html next to Script.ps1
.\Convert-Ps1ToHtml.ps1 -Path C:\Scripts\SQLTool.ps1
# Custom output and title
.\Convert-Ps1ToHtml.ps1 -Path .\SQLTool.ps1 -OutFile .\SQLTool-source.html -Title 'SQLTool source'
# No line numbers
.\Convert-Ps1ToHtml.ps1 -Path .\SQLTool.ps1 -LineNumbers:$false
[System.Management.Automation.PSParser]::Tokenize (or the PSParser API available in the host) — large scripts are fine; very huge files may take a moment..ps1 as the source of truth.Convert-Ps1ToHtml.ps1