Quantcast
Viewing all articles
Browse latest Browse all 19214

EWS Bind error message

Exception calling "Bind" with "2" argument(s): "The request failed. The remote server returned an error: (401) Unauthor
ized."
At C:\Users\Administrator\Desktop\inbox.ps1:16 char:60
+ $inbox = [Microsoft.Exchange.WebServices.Data.Folder]::Bind <<<< ($service,$folderid)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

when i run script that contain code

$EWSManagedApiPath= "C:\Program Files\Microsoft\Exchange\Web Services\2.0\Microsoft.Exchange.WebServices.dll"
[void][Reflection.Assembly]::LoadFile($EWSManagedApiPath);
 if($EWSManagedApiPath){
     Write-Host "Found"
 }else{
         Write-Host "API was not found"
 }
$version=[Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP1
$service=New-Object Microsoft.Exchange.WebServices.Data.ExchangeService($version)
$cred= New-Object System.Net.NetworkCredential("Administrator","test@123","Contoso")

$service.Credentials=$cred
$uri=[System.Uri] "https://mail.Contoso.com/ews/exchange.asmx"
$service.Url=$uri
$folderid= New-Object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,"Administrator@contoso.com")
$inbox = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderid)




Viewing all articles
Browse latest Browse all 19214

Trending Articles