No snap-ins have been registered for Windows PowerShell version 2

I was getting this message in SPPower (http://sppower.codeplex.com/), an application I am building to run powershell commands from WPF.

“No snap-ins have been registered for Windows PowerShell version 2.”

The code was basically this:

using (PowerShell ps = PowerShell.Create()) {
PSSnapInException ex = null
ps.Runspace.RunspaceConfiguration.AddPSSnapIn("Microsoft.SharePoint.PowerShell", out ex);

Doing a search returned this helpful link:


This suggested it was something to do with the different OS architectures.

Then it hit me, i was developing on Vista x86, but needed it to run on Windows 2008 x64. So I went to the visual studio project, and found it was targeted to x86 platform. All i needed to do was change it to "Any CPU", so it works on both the development and target environments


WD My Passport Essential SE 1TB

Well, i got a dick smith gift card for christmas, so i needed to use it up, but there is not really much at DSE that i would buy. I decided to get an external hdd for backing up stuff on my laptop while traveling.

Though i have had a little trouble with WD Green drives lately in my NAS, i decided to stick with WD.

I wanted the portable small drive, with as much storage as i could get, 1TB, and preferably with a USB 3 interface. The My Passport Essential SE 1TB http://www.wdc.com/en/products/products.aspx?id=430 gave me all of those. I would have liked to have a 7200 rpm drive, but no it didn't have one of those. I suppose it doesn't really matter as i have no usb 3 ports ... yet.

I had a look at some reviews, and people seemed to think there was a lot of bloat ware. Not a good sign. And there was a virtual cd that could not be removed. Some more searching, and i found a tool to nuke the bloat http://www.dedoimedo.com/computers/passport-vcd.html, so i was pretty much set to buy.

When i got to the shop they had 500GB Essentials and 1TB Essential SEs. I couldn't remember if the "SE" was good or bad... I took a risk and bought the SE. Luckily it turns out that the "SE" probably means second edition, and it is the evolution of the product http://www.wdc.com/en/products/external/portable/

I opened the box, and to my dismay, i saw that the cable had some port on it i had never seen. Oh no, i thought, i have got suckered into getting a non-standard proprietary piece of hardware. Turns out though, that the port is really the micro usb 3.0 standard. http://www.wdc.com/en/products/resources/drivecompatibility/

Finally when i plugged the drive in, the bloat was there, but without the virtual cd drive. A quick format, and i had a perfect drive.


SharePoint 2010 List View Ribbon Missing

One thing that i find annoying with list views, is when you add any other web parts to the same page, they become an application page. This means you lose the breadcrumb view selector, and also the ribbon menu.

After playing around with this question i managed to find a solution.

Basically you trick the list view into thinking it is selected. So first, add a content editor web part to the page, then have a timer, that calls the WpClick() method, triggering the web part to be selected. Then the ribbon shows.



Ribbon CustomAction On All Lists

For a new component I am building, I wanted to allow users to perform an action on all lists. I thought about putting it in list settings, but hey this is 2011, lets put it in the ribbon. As i knew nothing about the ribbon it was a good opportunity to study for certification.

First i had to get a basic understanding of how it all worked, these pages helped a lot. (but you have to be careful of pages relating to the beta)


Adding a few simple buttons, i found out that adding a global button was not very straight forward. For starters most of the examples bind to lists, but i wanted to bind to all lists. Easy enough to change the RegistrationType to ContentType, just like you do with workflows and then the RegistrationId would be 0x01, the root content type of everything.

I tried to apply what i had learnt from the examples, to this global button, but it ended up in a mess.
Take these two list types as examples:
100 (GenericList) has a ContextualGroup "List Tools" with Tab "Items" and "List"
101 (DocumentLibrary) has a ContextualGroup "Library Tools" with Tabs "Documents" and "Library"
Each list type has different and unique Location paths, so you need to have a CommandUIDefinition for each location. Sure, i could duplicate the CommandUIDefinition definitions, but eventually someone would add a new list definition, with a different ribbon, and my button would not display. And duplicating xml definitions bugs me. It must be pointed out though that some people would not want an extra tab cluttering up their ribbon.

Then it hit me, i didn't have to add this button to an existing tab, i could create my own and that way the Location would be the same, globally. First i tried to create it as a ContextualGroup. Why would i do that? Well it would be cool to have a ContextualGroup called say Custom and then developers could add their custom actions to it. Unfortunately i couldn't get it to work without code. ContextualGroups need to be showed from code, which kind of makes sense (because they are contextual). So i just ended up with a simple Tab instead.

I ended up with something like this

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<CommandUIDefinition Location="Ribbon.Tabs._children">
Description="Extended Settings"
Size="Large" />
Size="Large" />
<Groups Id="Ribbon.Extended.Groups">
Description="SPC3 Settings"
<Controls Id="Ribbon.Extended.SPC3.Controls">
LabelText="Show In"
ToolTipTitle="Show In"
ToolTipDescription="Opens Show In configuration"
Alt="Show In" />
<CommandUIDefinition Location="Ribbon.Templates._children">
<GroupTemplate Id="Ribbon.Templates.ExtendedLarge">
<Layout Title="Large" LayoutTitle="Large">
<Section Alignment="Top" Type="OneRow">
<ControlRef DisplayMode="Large" TemplateAlias="button1" />