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. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




My Recent Tweets

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 - WSO2 or anyone else for that matter. All trademarks acknowledged.

© 2007-2014 Dmitry Sotnikov

October 2007
M T W T F S S
« Sep   Nov »
1234567
891011121314
15161718192021
22232425262728
293031  

%d bloggers like this: