Copy Color-Coded PowerShell to HTML
In this FAQ, learn how to copy color-coded PowerShell from the Integrated Scripting Environment (ISE) to HTML.
July 18, 2013
Q: How can I copy Windows PowerShell code into a HTML page and keep the color highlighting of the text?
A: Often I create PowerShell code in the Windows 8 PowerShell Integrated Scripting Environment (ISE), which does a great job of color-coding the text to make it easy to understand the different elements. However, this gets lost as soon as it's pasted into HTML.
I found a great add-on for the ISE to enable the copying of PowerShell from the ISE into color-coded HTML. Perform the following:
Download the PowerShell Pack from Microsoft.
Install the downloaded MSI file.
Launch the PowerShell ISE.
Type the command below to import the PowerShell Pack module:
Import-Module PowerShellPack
On the ISE menu will be Add-ons, which will include a IsePack sub-menu.
Select the code in the Scripting pane, then go to Select Add-ons, IsePack, Edit, Copy-ColoredAsHtml (see screen shot below).
In your HTML editor in the Source view, select Paste, which will have the color-formatted HTML as the example shows below:
About the Author
You May Also Like