Remove in-place archive for Office 365 user

I need to remove the in-place archive for an Office 365 user that is DirSync'd from AD.

I've tried the following command in powershell and also tried disabling the archive in the EAC but getting an error:

Command: Disable-Mailbox -identity "user" -archive

Error: The action 'Disable-Mailbox','Archive', can't be performed on the object 'user' because the object is being synchronised from your on-premises organisation. This action should be performed on the object in your on-premises organisation.

I have looked at the attributes on the user's object in AD. I cannot change the msExchArchiveStatus from 1 to 0 or nothing as it is repopulated with 1 when the DirSync runs. I have also changed the msExchRemoteRecipientType from 3 to 1 (as it was changed from 1 to 3 when the archive was originally added) but this has made no difference.

I assume I am missing a step but am struggling to work out what it is, please help.
ISGIT2009Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vasil Michev (MVP)Commented:
So you are dirsync only, no hybrid? If I remember correctly, msExchArchiveStatus is only written back when the "hybrid" checkbox is enabled on dirsync. So have you enabled that checkbox, and if so, try reruning the dirsync setup wizard and uncheck it.

Might be wrong though, I'll double-check tomorrow when I'm at the office :)
ISGIT2009Author Commented:
Yes, we are DirSync only, no hybrid server on site.
Vasil Michev (MVP)Commented:
Sorry, totally forgot to check back on this. I have no problem removing In-place archive in the same scenario as yours (no Exchange on-prem, only dirsync). The msExchArchiveStatus will only be written back if you have configured dirsync with the "Hybrid" option, so just rerun the dirsync configuration wizard and make sure the checkbox for Hybrid is not selected. Then you should be able to push the attribute value from on-prem.
CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

ISGIT2009Author Commented:
Ok, I've done that, the attribute has not come back yet, how long does it take before the association with the archive is removed in Outlook and the EAC?
Vasil Michev (MVP)Commented:
That's the part that still puzzles me, you shouldn't have any issue with removing it using Disable-Mailbox in the first place. Have you tried running the cmdlet now, or removing the archive using the EAC?
ISGIT2009Author Commented:
Yes, already tried the cmdlet and EAC, still the same errors.
Vasil Michev (MVP)Commented:
What's the value for RemoteRecipientType and for ArchiveState? I guess it was migrated from on-prem Exchange? In such case, you should be using Disable-RemoteMailbox -Archive, but if there's no longer local Exchange, you can try pushing the relevant attribute values via Dirsync instead.

Can you also try 'refreshing' the archive state using Enable-Mailbox -Archive?

If you feel adventurous, you can filter out the corresponding user object via Dirsync, which will result in deleting the cloud object as well. The idea here is that you will then be able to recover the user from the Recycle bin (and reconnect the mailbox), which in turn will transfer the source of authority to the cloud, allowing you to change his attributes. Obviously not an ideal solution, but it's relatively safe to use. Or you can disable dirsync altogether, and run the cmdlet then (note that lately disabling dirsync seems to take a lot more time).
ISGIT2009Author Commented:
We've never had an on-prem Exchange. RemoteRecipientType is set to 1 (I changed this from 3). ArchiveStatus in AD is not populated. ArchiveStatus on the mailbox is "Active" and ArchiveState is "Local" (found by running Get-Mailbox "user" | fl *archive*)

Enable-Mailbox "user" -Archive tells me that the user already has an archive.
ISGIT2009Author Commented:
Get-Mailbox "user" |FL *remoterecipient* returns "ProvisionMailbox" for this particular user.

The same command on my mailbox returns "ProvisionMailbox, ProvisionArchive".

We previously migrated from IBM Domino to Office 365. Any migrated mailboxes seem to have "ProvisionMailbox" set for this attribute, any new users since the migration have this attribute set to "None".
Vasil Michev (MVP)Commented:
OK, I reproduced the issue, to solve it do the following:

Locate the object on-prem, and CLEAR the values for msExchRemoteRecipientType (double-click the attribute, press clear) and msExchArchiveName (clear the name, though I doubt that part matters that much). This will clear the RemoteRecipientType on the cloud object after next sync, so it should read "None". You will then be able to run the Disable-Mailbox -Archive cmdlet.

To be on the safe side, and probably speed things up a bit, "Touch" the on-prem object (i.e. change any other attribute, say extensionAttribute10), otherwise dirsync might not pick up the changes (you can monitor the MIISClient to check if the object is actually picked up as changed).

It is still not clear to me why you have RemoteRecipientType set like this, especially if you have migrated from Domino. In the future, just use the EAC or remote PowerShell to configure the archive, it will give you less trouble.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ISGIT2009Author Commented:
That's done it!

I guess it's the migration environment that has configured this attribute as it is not populated on new users.

Thanks for your help with this, it's very much appreciated.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Office 365

From novice to tech pro — start learning today.