Need help with powershell and EWS...
Any idea why this code works on two other workstations but doesn't work on another? I've included the code and here is the error I'm getting: Exception calling "AutodiscoverUrl" with "1" argument(s): "The type initializer for 'Microsoft.Exchange.WebServices.Strings' threw an exception." At line:14 char:29 + $exchService.AutodiscoverUrl <<<< ($mailbox) + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException $mailbox = 'xxxxx@yyyy.com' Import-Module -Name "C:\Program Files\Microsoft\Exchange\Web Services\2.0\Microsoft.Exchange.WebServices.dll" $exchService = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP2) $exchService.UseDefaultCredentials = $true $exchService.AutodiscoverUrl($mailbox) Anthony
September 19th, 2012 8:43am

Sorry to ask such an obvious question, but have you definitely installed the EWS Managed API dll on the affected workstation, and is it at the same location C:\Program Files\Microsoft\Exchange\Web Services\2.0\Microsoft.Exchange.WebServices.dll Mobile OWA For Smartphone www.leederbyshire.com email a@t leederbyshire d.0.t c.0.m
Free Windows Admin Tool Kit Click here and download it now
September 19th, 2012 9:04am

Yes. I installed versions 1.1, 1.2, and 2.0 on all three workstations. The script works using all three versions of the .dll on workstations 1 and 2. My new workstation, workstation 3, fails with the erorr I indicated.Anthony
September 19th, 2012 9:21am

The error message it's giving isn't the most helpful. Is there anything in any of the event logs? Does it make any difference if you tell it to not use the default credentials, and supply some explicitly? Or, is it practical to hard-code the url, rather than autodiscover it?Mobile OWA For Smartphone www.leederbyshire.com email a@t leederbyshire d.0.t c.0.m
Free Windows Admin Tool Kit Click here and download it now
September 19th, 2012 9:36am

I was running from powergui. When I ran from the powershell command line I received this error: Import-Module : Could not load file or assembly 'file:///C:\Program Files\Microsoft\Exchange\Web Services\2.0\Microsoft.Exchange.WebServices.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. Anthony
September 19th, 2012 10:58am

Does the affected machine have the same version of the .Net framework as the others? Can you verify that the good ones are not running a later version?Mobile OWA For Smartphone www.leederbyshire.com email a@t leederbyshire d.0.t c.0.m
Free Windows Admin Tool Kit Click here and download it now
September 19th, 2012 11:09am

Does the affected machine have the same version of the .Net framework as the others? Can you verify that the good ones are not running a later version?Mobile OWA For Smartphone www.leederbyshire.com email a@t leederbyshire d.0.t c.0.m
September 19th, 2012 11:09am

Hi Anthony, Any updates? By the way, I would also suggest you seek the solution in the Development forum: http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/threads Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.Frank Wang TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
September 20th, 2012 5:07am

Hi Anthony, Any updates? By the way, I would also suggest you seek the solution in the Development forum: http://social.technet.microsoft.com/Forums/en-US/exchangesvrdevelopment/threads Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.Frank Wang TechNet Community Support
September 20th, 2012 5:22am

Hi Anthony, Any updates?Frank Wang TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
September 23rd, 2012 9:48pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics