Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
I’ve developed a windows service developed in Visual Studio 2010 which performs Exchange 2007 administrative tasks and I’m moving it from a 32-bit development server to a 64-bit production server. The service accepts arguments and then invokes PowerShell to execute commands in the Exchange 2007 snap in.
 
It works correctly in the development environment both in the debugger and in the windows service itself after it’s been installed; unfortunately, when I copied the project to the new Windows 2008 R2 64-bit server and built it I can only get the service to work in the VS2010 debugger. When installed as a windows service on the 64-bit server the service consistently fails with a message from the PowerShell component of the code which reads:
“No snap-ins have been registered for Windows PowerShell version 2”
The C# code fails on a specific line when the PowerShell instance is invoked:
RunspaceConfiguration rc;
PSSnapInInfo info = rc.AddPSSSnapIn(“Microsoft.Exchange.Management.PowerShell.Admin”, out warning);
As I mentioned, the code will work so long as I run it in the VS2010 debugger.
 
To try and fix this I’ve tried Googling the error and come up with many other people having this problem but no-one having a definitive answer to it. Following some of the leads left in some of these postings I’ve tried these things:
  • I have removed and re-installed the Exchange 2007 management tools
  • I have done a “Get-PSSnapin” from the Exchange Management Shell PowerShell prompt (and got back a listing for the Exchange admin tools that looks like this – the version says that it’s for PSVersion 1.0 rather than 2.0 but, since things work in my VS2010 debugger, I thought that the psversion was not what was causing the problem):
  • Name: Microsoft.Exchange.Management.PowerShell.Admin
    • PSVersion: 1.0
    • Description: Admin Tasks for the Exchange Server
    • I’ve tried registering the snap-in using INSTALLUTIL under the C:\Windows\Microsoft.NET\Framework64\v2.0.50727 as
      Installutil c:\program files\microsoft\exchange server\bin\microsoft.exchange.management.dll
 
But I’m still stuck running the code in the debugger until I can get it working as a service.
 
From the tenor of the messages I’ve read about this this is a problem that a lot of people have had but no-one’s been able to completely fix as yet. Can anyone offer any help?
Posted 11-Aug-11 9:16am
Edited 11-Aug-11 9:21am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try registering the snap-in using C:\Windows\Microsoft.NET\Framework\v2.0.50727
InstallUtil c:\program files\microsoft\exchange server\bin\microsoft.exchange.powershell.Configuration.dll
 
Note the difference is in using 32bit version of InstallUtil
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 587
1 Sergey Alexandrovich Kryukov 479
2 Maciej Los 305
3 Mathew Soji 195
4 Afzaal Ahmad Zeeshan 170
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,777
2 DamithSL 5,461
3 Manas Bhardwaj 4,916
4 Maciej Los 4,475


Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 16 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100