Copy Color-Coded PowerShell to HTML

In this FAQ, learn how to copy color-coded PowerShell from the Integrated Scripting Environment (ISE) to HTML.

John Savill

July 18, 2013

1 Min Read
Copy Color-Coded PowerShell to HTML

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:

  1. Download the PowerShell Pack from Microsoft.

  2. Install the downloaded MSI file.

  3. Launch the PowerShell ISE.

  4. Type the command below to import the PowerShell Pack module:

    Import-Module PowerShellPack
  5. On the ISE menu will be Add-ons, which will include a IsePack sub-menu.

  6. Select the code in the Scripting pane, then go to Select Add-ons,  IsePack, Edit, Copy-ColoredAsHtml (see screen shot below).

  7. 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

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like