By Bjorn Houben
When sharing PowerShell scripts on the Internet there are a couple of options:
Simply post it as plain text, which means syntax highlighting will not be included.
Use available syntax highlighting for the platform you use. Sample platforms include:
Microsoft ScriptCenter and a syntax highlighting example from a script of mine: https://gallery.technet.microsoft.com/scriptcenter/Determine-possible-values-eaf48782
Wordpress : https://en.support.wordpress.com/code/posting-source-code/
Copy code to HTML including syntax highlighting.
Option 2 and 3 are preferred, especially sharing to Microsoft ScriptCenter because others can then more easily find and use your scripts and maybe even improve them or give you tips on how to make better script.
Option 2 however requires that you have to accept whatever the platform provider has chosen with regards to syntax highlighting, which might differ between platforms. With option 3 you have more freedom with regards to the output and you are in control. Basically it means copying code to HTML including syntax highlighting. The solution I use mostly for this is the Windows PowerShell V3 ISE: Copy As HTML Add-On which adds a simple “Copy As HTML” option in the menu and which can also be used using the shortcut CTRL+SHIFT+C.
I don’t have experience with it, but you …read more
Read more here:: Bjorn Houben