none
Issues Using powershell and forcing creds to check a mailbox RRS feed

  • Question

  • I have a bit of a over complicated environment.

    I'm using EWS with powershell to access a shared mailbox. It works perfectly fine using passthrough creds. I want to use a non mail enabled account to access a shared mailbox. I'm just not sure why I keep getting auth failures

    my email: first.last@part1.domain.com
    my login: Site1\userid1 (not remotely similar to my email)

    This works perfectly fine

    $ExchangeVersion = [Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP2
    $mailboxName = "SharedMailboxg@part1.domain.com"
    
    $service = New-Object -TypeName Microsoft.Exchange.WebServices.Data.ExchangeService -ArgumentList $ExchangeVersion
    
    #Credentials Option 1 - current creds
    $service.UseDefaultCredentials = $true
    
    
    $service.AutodiscoverUrl($mailboxName)

    I want to force creds, and I get multiple failures. I thought this is what I needed to force creds, but it's not working

    $creds = New-Object System.Net.NetworkCredential("user@domain.com","password")   
    $service.Credentials = $creds
    When I do $service.AutodiscoverUrl($mailboxName), I get an auth failure
    Exception calling "AutodiscoverUrl" with "1" argument(s): "Autodiscover blocked a potentially insecure redirection to 
    https://autodiscover.part1.domain.com/autodiscover/autodiscover.xml. To allow Autodiscover to follow the redirection, use the AutodiscoverUrl(string, 
    AutodiscoverRedirectionUrlValidationCallback) overload."
    At line:1 char:1
    + $service.AutodiscoverUrl($mailboxName)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : AutodiscoverLocalException

    When I try $tfTargetFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$RootFolderId

    I get the following error

    Exception calling "Bind" with "2" argument(s): "The request failed. The remote server returned an error: (401) Unauthorized."
    At line:1 char:1
    + $tfTargetFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind( ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : ServiceRequestException
    This happens if I specify my creds which worked with defaultcredentials=True

    Wednesday, October 12, 2016 6:42 PM

All replies