When one starts the 2010 Exchange Management Shell, a Powershell session opens, which loads a custom script file - RemoteExchange.ps1 that sets up the environment in order for the admin to be able to run the various cmdlets. I'm trying to access those same types and the cmdlets loaded by this script file from within LINQPad (this tool allows - among its many features - to run C# statements and can display the results in a nice "drill-able" form).
Close to the beginning of the RemoteExchange.ps1, "Microsoft.Exchange.Configuration.ObjectModel.dll" is being loaded, for which a reference can be added as an equivalent. So it's ok until this point.
Now things get tricky because one of the next line is:
$typeLoadResult = [Microsoft.Exchange.Configuration.Tasks.TaskHelper]::TryLoadExchangeTypes($ManagementPath, $typeListToCheck)
$ManagementPath is a Powershell variable containing the absolute path to "Microsoft.Exchange.Management.dll", while $typeListToCheck is a list of types to be loaded. Unfortunately the TaskHelper class doesn't look to be documented on MSDN, so I'm not really sure what happens behind the scenes here. Even if I go ahead and call the TryLoadExchangeTypes static method with some types, those same types aren't recognized afterwards. Any idea on how to fix this ?
As for LINQPad - my scenario doesn't have anything specific to this application, and the same C# statements could be very well be typed inside Visual Studio, generating the same outcome.