michelderooij / Remove-DuplicateItems

Script to remove duplicate items from Exchange mailboxes.

Home Page:https://eightwone.com/2013/06/21/removing-duplicate-items-from-a-mailbox/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot bind to MsgFolderRoot - skipping. Error: Exception calling "Bind" with "2" argument(s)

billbraz opened this issue · comments

Hello,

I wasn't sure where to post this, so here goes...

I get a Cannot bind to MsgFolderRoot - skipping. Error: Exception calling "Bind" with "2" argument(s) error when running this script. I'm running PS 5.1 on a 2016 server. I looked all over gallery.technet but couldn't find a solution. Here is the command I'm using:

Remove-Duplicates.ps1 -identity me@home.com -type calendar -DeleteMode MoveToDeletedItems -Mode Full -Verbose -MailboxOnly

And here is more of the message:
WARNING: Cannot bind to MsgFolderRoot - skipping. Error: Exception calling "Bind" with "2" argument(s): "Connection did not succeed. Try again later., Cannot open mailbox /O=home/OU=office/cn=Recipients/cn=me."

Any idea why it's failing, or what else I could try? Thanks in advance!

No idea why it's returning the legacyExchangeDN- are you running this on-premises?
Please re-open when it still happens.

Hi,

I have quite the same issue. When I try this command

PS C:\Users\administrateur\Downloads\Remove-DuplicateItems-master> .\Remove-DuplicateItems.ps1 -Identity myusers@myoffice.com -DeleteMode MoveToDeletedItems -Mode Full -retain Oldest -credentials admin@myoffice.onmicrosoft.com -Server outlook.office365.com -mailboxOnly -CleanUpMode mailbox -WhatIf -Verbose

I have this result
COMMENTAIRES : Module Microsoft.Exchange.WebServices v2.2.1.0 already loaded
COMMENTAIRES : Module Microsoft.Identity.Client v4.25.0.0 already loaded
COMMENTAIRES : Using credentials admin@myoffice.onmicrosoft.com
COMMENTAIRES : Cleanup Mode: mailbox
Processing mailbox myusers@myoffice.com (myusers@myoffice.com)
COMMENTAIRES : Using Exchange Web Services URL https://outlook.office365.com/EWS/Exchange.asmx
COMMENTAIRES : Constructing folder matching rules
AVERTISSEMENT : Cannot bind to MsgFolderRoot: Exception lors de l'appel de « Bind » avec « 2 » argument(s) : « The request failed. La connexion sous-jacente a été fermée : Une erreur inattendue s'est produite lors de
l'envoi. »

PS C:\Users\administrateur\Downloads\Remove-DuplicateItems-master>

It seems that this warning prevents the analysis of the "MsgFolderRoot" folder and, at the end prevents the scripts to find duplicates items.
Anyway, I excpected to have a list of duplicated items with what-if option.

is my diagnosis correct ? Or do you think the script runs correctly ? If not, do you have any idea ?

Vincent

"La connexion sous-jacente a été fermée : Une erreur inattendue s'est produite lors de l'envoi."
translated to problem during send, which gives me reason to suspect your connection when the script wants to establish a connection (Exchange Online).
To be sure, TLS12 is enabled on your system (WS2016)?
What does [System.Net.ServicePointManager]::SecurityProtocol output in PowerShell?
Does running this before starting the script help (by enabling TLS12 in your current PowerShell session):
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12

Hi Michel !

There is a change...
When I run first [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12
the error's message changes... I have now an 401 error :/

Processing mailbox myusers@myoffice.com (myusers@myoffice.com)
COMMENTAIRES : Using myusers@myoffice.com for impersonation
COMMENTAIRES : Using Exchange Web Services URL https://outlook.office365.com/EWS/Exchange.asmx
COMMENTAIRES : Constructing folder matching rules
AVERTISSEMENT : Cannot bind to MsgFolderRoot: Exception lors de l'appel de « Bind » avec « 2 » argument(s) : « The request failed. Le serveur distant a retourné une erreur : (401) Non autorisé. »

I am running script with admin's tenant administrator and I fully delegate the mailbox myusers@myoffice.com to administrator.

I wonder if this is not due to multi-factor authentication

Hi !
indeed, it was due to multi-factor authentication.
I created an app password and now the script works.

Thanks for help !