Add rights to archive Office365 SharePoint Online/OneDrive attachments

  • 7020596
  • 09-Dec-2015
  • 07-Aug-2017


Retain 4.x
Exchange Module


Retain throws errors when attempting to archive attachments saved in SharePoint/OneDrive


In Office365 you can attach documents stored in SharePoint Online/OneDrive. However it doesn’t send the actual document but only a link to that document.

So when Retain attempts to archive an attached document it often runs into trouble because the retain user, while it does have ApplicationImpersonation right, doesn’t have rights to anything outside of Exchange. So Retain will error because it knows there is supposed to be something there but can’t reach it.

11:04:16, 704[Thread-4920] [ERROR] ExchangeAttachment: error while creating attachment. SharePointError - Impersonation has no access to: attachments/office 365 users(1) (1).txt

What needs to be done is the retain user needs be added as a “site collection administrator” in SharePoint/OneDrive. Start by going to the Office365 admin page and selecting SharePoint.

Office 365 admin center

Go to the Site Collections, select the collection to add the retain user too, click the “Owners” tab.

sharepoint admin center

You can now add the retain user as a “Site collection administrator”. This way the retain user will have rights to access the data.

manage adminstrators

This works for individual site collections, but it would be difficult to do that individually if you have many site collections. There is no way in SharePoint to change more than one collection at a time.

Changing Across The Domain
However, there is a SharePoint Online Management Shell script that you could modify for use to do all site collections at once.

You may have to change the Execution Policy to get the script to run. The following command will allow execution for the current Powershell session.

Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process

Additional Information

This article was originally published in the GWAVA knowledgebase as article ID 2674.