Register Powershell SnapIn to specific version of Powershell

1.3k views Asked by At

I am trying to run an Exchange Management Shell script via managed code. Our PowerShell version is version 4. I am trying to use the runspaceConfiguration.AddPSSnapin() method to add the exchange SnapIn Microsoft.Exchange.Management.Powershell.E2010, however this line fails, giving :

no snapins have been registered for Powershell version 4.

A quick Get-PSSnapIn -registered shows the SnapIn is installed but registered to PS version 1.

In regEdit, I have found the registry key for the snapIn for PowerShell v1, used the export function to script the key, changed the target version to 4 and ran the export command, which has created the new key '4' under PowerShell as expected, with the snapin details copied across. However I still get the 'no snapins have been registered for Powershell version 4.', even though the key is there in the registry.

Is there something else I should be doing to register the snapin to PowerShell version 4?

Thank you for your time.

1

There are 1 answers

0
Adamski343 On BEST ANSWER

You are correct in that this is a 32/64 bit build issue. After I set the target build to x64 in VS and redeployed, all magically seemed to work fine. The error message regarding Powershell versions is a massive Red Herring in this case.