Here is the code that works on my old workstation that has EWS API 1.1:
$mailbox = 'XXXX@XXX.com' Import-Module -Name "C:\Program Files\Microsoft\Exchange\Web Services\1.2\Microsoft.Exchange.WebServices.dll" $exchService = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService $exchService.UseDefaultCredentials = $true $exchService.AutodiscoverUrl($mailbox)
When it hits the $exchService.AutodiscoverUrl line in my new workstation with both 1.2 and 2.0 preview API on it I get this exception. I'm wondering if any of you have any idea why I'm getting this and help me out?
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
Anthony