2

I am trying to add the Exchange 2007 SnapIn for 32-bit Powershell (Microsoft.Exchange.Management.PowerShell.Admin) but I seem to be having some trouble when installing the dll file.

These are the commands I am running in order to register the SnapIns

PS C:\Program Files\Microsoft\Exchange Server\Bin> $snapinPath = 'Microsoft.Exchange.Management.PowerShell.Support.dll'
PS C:\Program Files\Microsoft\Exchange Server\Bin> C:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe /i $snapinPath

The above works without issue. I then go to install the main SnapIn with the following commands:

PS C:\Program Files\Microsoft\Exchange Server\Bin> $snapinPath = 'Microsoft.Exchange.PowerShell.Configuration.dll'
PS C:\Program Files\Microsoft\Exchange Server\Bin> C:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe /i $snapinPath

Microsoft (R) .NET Framework Installation utility Version 2.0.50727.5483 Copyright (c) Microsoft Corporation. All rights reserved.

Exception occurred while initializing the installation: System.BadImageFormatException: Could not load file or assembly 'Microsoft.Exchange.PowerShell.Configuration, Version=8. 0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. An attempt was made to load a program with an incorrect format..

I'm not sure what I'm missing here. It's a fresh Exchange 2007 install so nothing should be corrupt.

Saintwolf
  • 699
  • 1
  • 6
  • 19
  • 1
    Are you sure you're running the 32-bit PowerShell? That error is most likely to do with loading a 32-bit-only assembly in a 64-bit application or vice versa. – makhdumi May 26 '15 at 00:17
  • Well as far as I'm aware the DLL should be platform-independent, which would make sense as to why the first DLL registered, but can't understand why the second didn't. – Saintwolf May 26 '15 at 00:18
  • Ah, maybe the .NET version of the assembly is > 2.0? You're using the (64-bit?) InstallUtil.exe from .NET 2.0. – makhdumi May 26 '15 at 00:21
  • 3
    Also see [this post](http://stackoverflow.com/questions/270531/how-to-determine-if-a-net-assembly-was-built-for-x86-or-x64) which can be used to determine which architecture the assembly was compiled for. Try running filemon to see what gets accessed from where to see if there is any path confusion. Another thing, does this assembly have any native code dependencies, those will need to match the architecture of the process as well. – Chris O May 26 '15 at 00:25
  • Thanks Chris. ProcessorArchitecture : Amd64. Looks like I'll need to copy the DLL from the 32-bit version of Exchange. Thanks :) – Saintwolf May 26 '15 at 00:37

1 Answers1

0

My issue was that I was using the 64-bit version of the Microsoft.Exchange.PowerShell.Configuration.dll.

I required the 32-bit version. As it did not allow me to install the 32-bit version, I extracted the setup files for the 32-bit version of exchange, and copied the setup\serverroles\common folder to C:\Program Files\Microsoft\Exchange Server, and renamed it to Bin32.

The final stage was to copy this registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.Exchange.Management.PowerShell.Admin

to the following location:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.Exchange.Management.PowerShell.Admin

and then change any paths within the key to point to the new Bin32 folder.

At this point, it should be possible to load the Microsoft.Exchange.Management.Powershell.Admin snapin into a 32-bit Powershell (Great for IIS apps which depend on 32-bit libraries).

Saintwolf
  • 699
  • 1
  • 6
  • 19