You might want to insert formatted and colored code syntax (the colorized and formatted script code is easier to read on Web pages and stands out a lot more). This will help readers understand the syntax faster when they read it.
Inserting code into the Wiki-editor can be a little tricky if you want Windows PowerShell code syntax formatting. This article assumes that you are using Windows PowerShell ISE (that is a part of PowerShell V2) or PowerGUI Script Editor from Quest Software.
##################################################################### # Test-Me.ps1 # Version 0.63 # # This script just tests something # ##################################################################### #requires -Version 2.0 function Test-Me { [CmdletBinding()] param ( [Parameter(Mandatory = $true, ValueFromPipeline = $true, Position = 0)] [string]$Argument ) Write-Host "You have passed the following argument to me:" Write-Host $Argument }
This article is also available in other languages:
Benoit Jester edited Revision 25. Comment: Add french link
Richard Mueller edited Revision 22. Comment: Replaced RGB values with color names in HTML to restore colors
Richard Mueller edited Revision 20. Comment: Added TOC and tag
Richard Mueller edited Revision 19. Comment: Removed (en-US) from title, added tag
Fernando Lugão Veltem edited Revision 17. Comment: added link to translated article Como Inserir Código Formatado do Windows PowerShell no TechNet Wiki (pt-BR)
Craig Lussier edited Revision 15. Comment: added en-US to tags and title
yottun8 edited Revision 14. Comment: Japanese article's link Added.
FZB edited Revision 13. Comment: other languages added
Karl Mitschke edited Revision 12. Comment: Minor spoelling issue (HTLM instead of HTML in PowerGUI section)
Ed Price MSFT edited Revision 8. Comment: Added "See Also" section.
Vadims Podans edited Revision 3. Comment: removed 'work in progress' header
Before I learned how to do this, I would want to know WHY I would want to do this. Any insight?
I believe that colorized and formatted script code is more readable on web pages, rather unformatted and uncolored code.
Ed Price MSFT edited Revision 6. Comment: Added the missing "Why" statement at the top. And updated title casing.
Thanks for adding that info!
Useful information.
Do you know if such a method can be used for any other kind of script snippets?
> Do you know if such a method can be used for any other kind of script snippets?
if you are using one of these script editors — yes.
As a techie, I appreciate options when it comes to stuff like this, but I gotta say, the PowerGUI code coloring scheme just doesn't look right to me after using the PSISE for so long. As a standard, I would recommend anyone looking to post colored code to use the PowerShell ISE from Microsoft.
Good Article.