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:52am

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:14am

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:30am

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:45am

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 11:07am

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:19am

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

Other recent topics Other recent topics