PowerShell Highlight for your Blog

Just wanted to quickly blog about how I now manage to have nicely formatted PowerShell code snippets in my blog like this one:

for($i=0; $i -lt $csv.Count; $i++){   
   $command = "New-QADUser "

   $parameters | ForEach {

         $csvarg = Invoke-Expression ('$csv[$i].' + $_.Name)

         $arg = ' -' + $_.Name + ' "' + $csvarg + '"'

         $command = $command + $arg  
   }
   Invoke-Expression $command
}

What I do, is using a nice little feature of the PowerGUI Script Editor: Save As HTML. I basically save my scripts from PowerGUI as html files and then copy/paste the html code I need into the blog. Makes the posts much more readable than they used to be!

[UPDATE] This is even easier now. With recent versions of PowerGUI Script Editor, all you need to do is select the PowerShell code you need, and then on the Edit menu, click Copy As / HTML.

Tags: ,

0 Responses to “PowerShell Highlight for your Blog”


  1. No Comments

Leave a Reply




View Dmitry Sotnikov's profile on LinkedIn

Archives

See you at:

Legal

The posts on this blog are provided “as is” with no warranties and confer no rights. The opinions expressed on this site are mine and mine alone, and do not necessarily represent those of my employer Quest Software or anyone else for that matter. All trademarks acknowledged.

© 2007 Dmitry Sotnikov