Failing Exchange Transport Service after Policy Patrol 8 upgrade

Just had an issue on one of my Exchange 2010 (SP2 RU3) CAS servers when upgrading Policy Patrol from v7.x to v8.0. The install/upgrade completed successfully, but I noticed the following errors in the Application log afterwards:

Error 1052, MSExchange Extensibility
Failed to create agent factory for the agent 'Policy Patrol Email Edge' with error 'Failed to create type 'RedEarthSoftware.PolicyPatrol.Email.Agent.EdgeTransportFactory' from assembly 'C:Program Files (x86)Red Earth SoftwarePolicy Patrol EmailAgentPolicyPatrol.Email.Agent.dll' due to error 'Invalid agent assembly path.'.'. Please verify the corresponding transport agent assembly and dependencies with correct version are installed.

Error 16023, MSExchangeTransport
Microsoft Exchange couldn't start transport agents. The Microsoft Exchange Transport service will be stopped. Exception details: Failed to create type 'RedEarthSoftware.PolicyPatrol.Email.Agent.EdgeTransportFactory' from assembly 'C:Program Files (x86)Red Earth SoftwarePolicy Patrol EmailAgentPolicyPatrol.Email.Agent.dll' due to error 'Invalid agent assembly path.'. : Microsoft.Exchange.Data.ExchangeConfigurationException: Failed to create type 'RedEarthSoftware.PolicyPatrol.Email.Agent.EdgeTransportFactory' from assembly 'C:Program Files (x86)Red Earth SoftwarePolicy Patrol EmailAgentPolicyPatrol.Email.Agent.dll' due to error 'Invalid agent assembly path.'. ---> System.ArgumentException: Invalid agent assembly path.
   --- End of inner exception stack trace ---
   at Microsoft.Exchange.Data.Transport.Internal.MExRuntime.FactoryTable.CreateAgentFactory(AgentInfo agentInfo)
   at Microsoft.Exchange.Data.Transport.Internal.MExRuntime.FactoryTable..ctor(IEnumerable agents)
   at Microsoft.Exchange.Data.Transport.Internal.MExRuntime.RuntimeSettings..ctor(MExConfiguration config, String agentGroup)
   at Microsoft.Exchange.Data.Transport.Internal.MExRuntime.MExRuntime.Initialize(String configFile, String agentGroup, Boolean isBridgeHead, String installPath)
   at Microsoft.Exchange.Transport.Extensibility.AgentComponent.Load()

The Microsoft Exchange Transport service was failing because it seemed that the transport agent configuration hadn’t been updated as part of the upgrade. This was caused by issues with the Exchange Management Shell on the server in question. I found this in the Policy Patrol install logs:

ERROR:The Windows PowerShell snap-in 'Microsoft.Exchange.Management.PowerShell.Admin' is not installed on this machine.
ERROR:The Windows PowerShell snap-in 'Microsoft.Exchange.Management.PowerShell.E2010' is not installed on this machine.

Luckily, I had another server to reference, so this is what I did to resolve the problem:

  1. Stopped the Policy Patrol services
  2. Opened a new EMS (Exchange Management Shell) window and did this:
    1. Uninstall-TransportAgent “Policy Patrol Email Edge”
    2. Uninstall-TransportAgent “Policy Patrol Email Hub”
  3. Closed the EMS window, and restarted the Microsoft Exchange Transport service
  4. Opened a new EMS window, and did the following:
    1. Install-TransportAgent -Name “Policy Patrol Email Edge” -TransportAgentFactory “RedEarthSoftware.PolicyPatrol.Email.Engine.Ex2007.EdgeAgentFactory” -AssemblyPath “C:Program Files (x86)Red Earth SoftwarePolicy Patrol EmailPolicyPatrol.Email.Engine.Ex2007.Sink.dll”
    2. Install-TransportAgent -Name “Policy Patrol Email Hub” -TransportAgentFactory “RedEarthSoftware.PolicyPatrol.Email.Engine.Ex2007.PostCatAgentFactory” -AssemblyPath “C:Program Files (x86)Red Earth SoftwarePolicy Patrol EmailPolicyPatrol.Email.Engine.Ex2007.Sink.dll”
  5. Restarted the Microsoft Exchange Transport service
  6. Opened a new EMS window
    1. Enable-TransportAgent “Policy Patrol Email Edge”
    2. Enable-TransportAgent “Policy Patrol Email Hub”
  7. Restarted the Microsoft Exchange Transport service
  8. Started the Policy Patrol services

That’s it. No more issues loading the transport agents, and no more crashing Microsoft Exchange Transport service.

Update – 10/07/2012: Added some info about the cause of the problem.