My latest adventure was in the form of errors trying to run just about any command in the Exchange Management Shell (EMS).
The problem came in conjunction with a case where Exchange 2007 was blown away and reinstalled, with some setup problems along the way, as well as some intermittent mail flow and OWA problems. This was a combo CAS, Hub, and Mailbox server, and given the problems encountered by the prior engineers, I wasn’t sure what I could trust regarding the soundness of the install.
However, back to the EMS errors. Here is the kind of errors we were seeing:
[PS] C:\Documents and Settings\Administrator>Get-ExchangeServer
WARNING: An unexpected error has occurred and debug information is being
generated: Could not load file or assembly ‘Microsoft.Exchange.Extensibility.Internal, Version=22.214.171.124, Culture=neutral,
PublicKeyToken=31bf3856ad364e35′ or one of its dependencies. The system cannot find the file specified.
Get-ExchangeServer : Could not load file or assembly ‘Microsoft.Exchange.Extensibility.Internal, Version=126.96.36.199, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The system cannot find the file specified.
At line:1 char:19
+ Get-ExchangeServer <<<<
+ CategoryInfo : NotSpecified: (:) [Get-ExchangeServer], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.Exchange.Management.SystemConfigurationTasks.GetExchangeServer
However, all functions in the Exchange Management Console (EMC) worked fine.
To be able to remove and reinstall the Exchange Management Tools however, requires removing all of the Exchange Roles as well, so we first went through a lot of troubleshooting regarding seeing is assemblies were properly referenced in the registry, etc.
After completely uninstalling the server, and reinstalling just the Management Tools, we still got the same type of error in the EMS. So next I wanted to remove Powershell and reinstall it, but we were not able to find the Windows update (926139) listed in Add/Remove programs. Since I had output from our Support Diagnostics Platform (SDP) tool, I went searching for the Powershell update in the hotfixes list we get from the tool. One particular entry I found was very interesting:
02/14/2010 05:04:44 AM Install SYSTEM AutomaticUpdates KB968930
Windows PowerShell 2.0 and WinRM 2.0 for Windows Server 2003 x64 Edition (KB968930)
Powershell 2.0 on an Exchange 2007 server. This is not a good thing, at least not until Exchange 2007 SP2 is applied.
So, we went back into Add/Remove Programs, and did not see any reference to this update number. However, another entry caught my eye: Windows Management Framework
It turns out that the Windows Management Framework is the Powershell 2.0 and WinRM 2.0 package.
We removed Windows Management Framework, fired up the EMS, and now our commands worked perfectly!
So, if you ever encounter errors in Powershell like we saw above on your Exchange 2007 server, and you haven’t applied SP2, look for Powershell 2.0 or Windows Management Framework installed on the system and remove it. Or you can go ahead and update to Exchange 2007 SP2.
Thanks to a comment from Aleksandar of http://powershellers.blogspot.com/, I can now note that if SP2 is applied to your Exchange 2007 server or your management workstation, Powershell 2 is now supported and should work fine.