Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Exchange Web Services PS Script worked with API 1.1 but now doesn't with either 1.2 or 2.0 preview?

$
0
0

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


Viewing all articles
Browse latest Browse all 2562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>