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: PowerGUI, PowerShell
Subscribe by email






0 Responses to “PowerShell Highlight for your Blog”