Convert-Ps1ToHtml

Script: Convert-Ps1ToHtml.ps1 (keep a copy with your other ops scripts; often under C:\Scripts or the Chief of Staff working folder)
Requires: PowerShell 7+ (#requires -Version 7.0)

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.

Parameters

NameRequiredDefaultPurpose
PathYesSource script path (.ps1 or other text PowerShell file)
OutFileNoSame folder/name as Path with .htmlDestination HTML path
TitleNoSource file name<title> and heading text
LineNumbersNo$trueShow line-number gutter; pass -LineNumbers:$false to hide

Examples

# 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

What you get

Notes

See also