Here is a SlightlyPosher environment


On my personal laptop I use Console2 with a PowerShell environment loaded with useful modules like PSCX, PowerTab and LINQ. I needed to be able to use this on client machines, so I cleaned up the paths to be relative and uploaded it to a DropBox.

Now this worked great for me, however I wanted to share it with my work mates, so I needed an easier way of distributing it. Since I’ve gone through the effort why not share it with everyone.

Getting Started


  1. Download the latest from:
  2. Unzip
  3. Run Install.bat – This appends the SlightlyPosher profile to your PowerShell profile.
  4. Launch Console2
  5. That’s it!

Updating your environment


You can update the entire environment using update.bat. This will download the latest from GitHub and unzip it into your local directory.

This will wipe out any changes to make to existing files (but not delete new ones). So please fork the project on GitHub and send me pull requests for any changes you make. It will not override changes you make to the configuration for Console2 since everyone likes their console slightly different.

What you will get




Tab Completion


Balloon Notifications



Visual Studio Command Prompt


Get-SystemInternalsSuite (downloaded, unzipped and configured into your path)



Command line history


Even more stuff in modules

You can browse all the functions that are available and pre-loaded in the modules folder.



Since I’ve pulled in quite a bit of stuff from the web, it’s only fair that I credit others. I’ve done my best do put credits directly in the code. For example:


If you see code I’ve not credited, please let me know and I’ll add it in!



You can reach me @NaeemKhedarun

XmlLists with Psake / Powershell

On a POSH roll here, this time I needed to list out the Include attributes for references in an msbuild file. Let’s take a look at the POSH script equivalent of XmlList:

function xmlList([string]$file, [string]$xpath, [hashtable]$namespaces) { 
    [xml] $fileXml = Get-Content $file 
    $xmlNameTable = new-object System.Xml.NameTable
    $xmlNameSpace = new-object System.Xml.XmlNamespaceManager($xmlNameTable)

    foreach($key in $namespaces.keys)
        $xmlNameSpace.AddNamespace($key, $namespaces.$key);
    $nodes = @()
    $node = $fileXml.SelectNodes($xpath, $xmlNameSpace) 
    $node | ForEach-Object { $nodes += @($_.Value)}
    return $nodes

Now to use this we can do this:

$namespaces = @{ "xsi" = ""}
$xpath = "//xsi:Reference/xsi:HintPath/../@Include"

$nodes = xmlList "$examplesdest_dir\NBehave.Examples.csproj" $xpath $namespaces

And it gives us a list of the references in the msbuild file.


XmlPoking vsixmanifests with Psake / Powershell


Nant had some very useful XmlPoke and XmlPeek tasks for working with xml files. When manually installing visual studio plug-ins, the vsixmanifest needs to have some fields prodded to work correctly, specifically the InstalledByMsi and Version.

So here’s a POSH version of XmlPoke:

function xmlPoke([string]$file, [string]$xpath, $value, [hashtable]$namespaces) { 
    [xml] $fileXml = Get-Content $file 
    $xmlNameTable = new-object System.Xml.NameTable
    $xmlNameSpace = new-object System.Xml.XmlNamespaceManager($xmlNameTable)

    foreach($key in $namespaces.keys)
        $xmlNameSpace.AddNamespace($key, $namespaces.$key);
    $node = $fileXml.SelectSingleNode($xpath, $xmlNameSpace) 
    if ($node) { 
        $node.InnerText = $value 



And the usage for vsixmanifests is below, you will need to adjust the namespaces based on the xml you are prodding.

$namespaces = @{ "vsx" = ""}
$xpath = "/vsx:Vsix/vsx:Identifier/vsx:"
xmlPoke "$destination\extension.vsixmanifest" $xpath"InstalledByMsi" "true" $namespaces
xmlPoke "$destination\extension.vsixmanifest" $xpath"Version" $version $namespaces

ILMerging assemblies with Psake / Powershell


On NBehave I am migrating the existing build framework from Nant over to Psake, and am thoroughly enjoying the ability to debug and step through my build scripts.

We needed to merge some of our output assemblies before packaging, and this was extremely easy in POSH:

function ilmerge($key, $directory, $name, $assemblies, $extension)
    # Create a new temp directory as we cannot overwrite the main assembly being merged.
    new-item -path $directory -name "temp_merge" -type directory -ErrorAction SilentlyContinue
    # Unfortuntately we need to tell ILMerge its merging CLR 4 assemblies.
    if($framework -eq "4.0")
        Exec { tools\ilmerge\ilmerge.exe /keyfile:$key /out:"$directory\temp_merge\$name.$extension" "$directory\$name.$extension" $assemblies /targetplatform:"v4,$env:ProgramFiles\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0" }
        Exec { tools\ilmerge\ilmerge.exe /keyfile:$key /out:"$directory\temp_merge\$name.$extension" "$directory\$name.$extension" $assemblies }
    Get-ChildItem "$directory\temp_merge\**" -Include *.dll, *.pdb | Copy-Item -Destination $directory
    Remove-Item "$directory\temp_merge" -Recurse -ErrorAction SilentlyContinue

The parameters are straightforward and as you’d expect, here’s an example usage:

$key = "$solution_dir\NBehave.snk"
$directory = "$build_dir\dist\v$framework"
$name = "NBehave.Narrator.Framework"

$assemblies = @("$directory\gherkin.dll", 

ilmerge $key $directory $name $assemblies "dll"


The extension should be “.dll” or “.exe” depending on what the main artifact your trying to merge is.

Newer Posts Older Posts