Publishing source code from the PowerShell ISE to the web with BlogShell

by Klaus Graefensteiner 13. October 2010 19:21

Introducing BlogShell

Writing a blog post consists is a three step process. First you gather the material that your blog post will be talking about. There can be pictures, screenshots, movies, source code snippets, tabular data, music, links and attachments. These artifacts need to be put inline with the actual writing. This is the second step. The third task is to publish the content to the web. BlogShell helps with the second step. The putting it together. The first release of BlogShell is all about composing blog posts that contain source code snippets. The upcoming incarnations will go beyond that and help digesting media files, tabular data like CSV files and attachments.


Figure 1: BlogShell is for automating the composition of blog content


In its core BlogShell meshes up several tools that you might already use for blogging. If not get them since they are required to fully take advantage of BlogShell.

Read the following blog post to setup SyntaxHighlighter with BlogEngine.NET: Setting up SyntaxHighlighter for BlogEngine.NET in the bare bone fashion. There are also many extensions and plugins available for Wordpress and BlogEngine.NET.

Installation instructions

Installing BlogShell just requires a few manual steps.

Step 1:  Download and copy

Go to the project home page at and download the latest release. Then unzip the zip file and copy the BlogShell folder into the PowerShell Modules folder. In my case it is: C:\Users\Klaus\Documents\WindowsPowerShell\Modules

Note: Depending on your OS it might be different.


Figure 2: Unzip BlogShell after the download


Figure 3: Copy BlogShell into the PowerShell Modules folder

Step 2: Modify the PowerShell profile files

Open the PowerShell profile file which can be found in my case under C:\Users\Klaus\Documents\WindowsPowerShell\profile.ps1. Copy and paste the following code snippet.

#BlogShell: Setting up PATH environment variable to point to BlogShell framework
$BlogShellPath = "C:\Users\Klaus\SVN\PS\BlogShell"
#Make sure to only append this path once
if (!($env:path -like "*$BlogShellPath*"))
    $env:path = $env:path + ";$BlogShellPath"
#BlogShell: Setting BlogShell_HOME environment variable to point to BlogShell framework
If(! $(Test-Path -Path "env:BlogShell_HOME"))
    New-Item -Path "env:" -Name "BlogShell_HOME" -value $BlogShellPath

Modify PowerShell_ISE profile which is in my case C:\Users\Klaus\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1. Copy and paste the following code snippet.

"Importing the BlogShell Module"
import-module -name BlogShell -verbose

That is it.

BlogShell Installation Movie

The following screen recording demonstrates how easy it is to get BlogShell setup.

User Stories currently available

To quickly an overview what BlogShell can be used watch the following very short videos.

User Story 1

As a PowerShell developer and blogger I would like to encode source code for the use in Html <pre> tags.

User Story 2

As a PowerShell ISE user and blogger I would like to automatically create a stand-alone html page that can be used as preview or can be posted web site as static Html page. This page does syntax highlighting using the SyntaxHighlighter JavaScript library.

User Story 3

As PowerShell ISE user and blogger I would like to automatically generate a source code snippet, launch Windows Live Writer and prime it with the Html code snippet. The published page will take advantage of the SyntaxHighlighter JavaScript library.

User Story 4

As a PowerShell ISE user and blogger I would like to create a SyntaxHighlighter source code snippet for copying and pasting into the Windows Live Writer source view window. The html snippet contains the source code in a Html <pre> tag and the syntax brush based on the file extension. The file needs to exist on disk.

Upcoming User Stories

The following user stories are part of the BlogShell road map

Source Code Theme

  1. Publish selected text as code snippet.
  2. Publish folder of files as code snippets.
  3. Add selected source code snippets incrementally to an html file.
  4. Support for Drag and Drop publishing in the PowerShell ISE

Blog API Theme

  1. Publish code snippet directly to blog using current blog API’s
  2. Generate BlogEngine.NET blog post XML file from code snippet

IDE Integration Theme

  1. Support for Visual Studio
  2. Support for Power GUI

Content Theme

  1. Publish CSV file as html table
  2. Automatically zip source code and other files and add as attachment
  3. Insert screenshots or picture series into blog post


I hope BlogShell doesn’t just make my life as a blogger easier, but will also ease your blogging pain a little bit. Since almost everybody knows PowerShell by now Smile. It would make totally sense to add PowerShell support to Windows Live Writer. We shall see.

About Klaus Graefensteiner

I like the programming of machines.

Add to Google Reader or Homepage

LinkedIn FacebookTwitter View Klaus Graefensteiner's profile on Technorati
Klaus Graefensteiner

Klaus Graefensteiner
works as Developer In Test and is founder of the PowerShell Unit Testing Framework PSUnit. More...

Open Source Projects

PSUnit is a Unit Testing framwork for PowerShell. It is designed for simplicity and hosted by Codeplex.
BlogShell is The tool for lazy developers who like to automate the composition of blog content during the writing of a blog post. It is hosted by CodePlex.



Powered by:

Creative Commons License

© Copyright 2015, Klaus Graefensteiner.

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

Theme design:
This blog theme was designed and is copyrighted 2015 by Klaus Graefensteiner

Page rendered at 5/27/2015 8:41:08 AM (PST Pacific Standard Time UTC DST -7)