Script to Update msExchArchiveGuid and msExchArchiveName in bulk from Exchange Online to On-premise AD

Summary –

Use this script for errors like below on office 365 portal.

Failed to sync the ArchiveGuid 00000000-0000-0000-0000-000000000000 of mailbox 28b656595f-924b-4c5b-a4be-ea255450f  because one cloud archive 45e245ba67-a5ed-4408-8ced-a4d124521 exists

Note: Recommended way to resolve this issue is using On-premise Exchange PowerShell. But these steps are for those scenarios wherein we don’t have on-premise exchange to fix this but exchange attributes are there in AD schema.

Managing the Exchange Attributes for cloud users from AD PowerShell or from ADSIedit is not supported and we strongly recommend keeping an active Exchange Server in your Active directory with minimum roles, just for being able to manage the Exchange attributes that shall be synced to the cloud.

For more information about these recommendations, you might find interesting below public article:

https://technet.microsoft.com/en-us/library/dn931280(v=exchg.150).aspx

“The question of whether a third-party management tool or ADSIEDIT can be used is often asked. The answer is you can use them, but they are not supported. The Exchange Management Console, the Exchange Administration Center (EAC), and the Exchange Management Shell are the only supported tools that are available to manage Exchange recipients and objects. If you decide to use third-party management tools, it would be at your own risk. Third-party management tools often work fine, but Microsoft does not validate these tools. “

Who should use this?

It can be used for users for whom you are getting error like below.

Failed to sync the ArchiveGuid 00000000-0000-0000-0000-000000000000 of mailbox 28b656595f-924b-4c5b-a4be-ea255450f  because one cloud archive 45e245ba67-a5ed-4408-8ced-a4d124521 exists

What do you need to know before you begin?

  • Should have installed MsOnline module for Office 365.
  • Should have Global admin credentials for Office 365.
  • Should have logged in to domain controller with Enterprise Admin credentials.
  • Should have rights to execute scripts.

How you do this?

  1. Login to a domain controller which meets above per-requites.
  2. Download and extract attached zip file in any location on the server. For example, I extracted it under “C:\O365”. There should be below 4 files.

 

ArchiveGuid_Version1.0.ps1

ArchiveGuid_Version1.0_Menifest.psd1

ArchiveGuid_Version1.0_Module.psm1

ConnectingToResources.ps1

 

  1. Open Windows PowerShell as administrator on the machine and set the directory of script files. For example, below.

 

Set-Location “C:\O365”

 

  1. Run below command and you should be able to see script files. If they are not there then you have set wrong location on step 3.

 

Get-ChildItem

  1. Run below command to import module.

 

Import-Module .\ArchiveGuid_Version1.0_Menifest.psd1

 

  1. Run below command to connect to office 365 and when prompted enter Office 365 global admin credentials.

ConnectTo-office365

  1. Run below command to collect effected users data from Office 365.

Get-EffectedMsolUser -CSVPath “location for csv file”

For example:

Get-EffectedMsolUser -CSVPath "C:\O365\EffectedMsolUser.csv"

 

**CSVPath – Path where you want to extract CSV file of effected MSOL users. Suggested to use same path where you have script files.

 

  1. Run below command to collect effected mailboxes data from Office 365.

Get-EffectedMailboxes -MsolUserCSVPath "location of CSV file collected in step 7" -MailboxCSVPath "location to create effected mailbox csv file"

For example:

Get-EffectedMailboxes -MsolUserCSVPath "C:\O365\EffectedMsolUser.csv" -MailboxCSVPath "C:\O365\EffectedMailboxes.csv"

 

**MsolUserCSVPath – Path of CSV file collected in step 7.

**MailboxCSVPath – Location to create effected mailboxes csv. Suggested to use same path where you have script files.

 

  1. Run below command to see effected AD accounts in your on-premise active directory. Output of this will show samAccountName of users where Archive Guid and name needs to be set.

 

Get-EffectedAdUser -EffectedMailboxCsvPath "location of CSV file generated in step 8" -EffectedPartition 'Domain partition where you want to search'

 

For example:

Get-EffectedAdUser -EffectedMailboxCsvPath "C:\O365\EffectedMailboxes.csv" -EffectedPartition 'DC=hckoffice365,DC=in'

 

**EffectedMailboxCsvPath – Location of CSV file generated in step 8. In my case its “C:\O365\EffectedMailboxes.csv”

**EffectedPartition (Not Mandatory) – Domain partition where you want to search and set the attributes. If you don’t mention this attribute, then script will take root partition by default.

 

  1. Run below command to set Archive Guid and Archive Name values on effected user accounts.

 

Set-msExchArchiveInfo -EffectedMailboxCsvPath "location of CSV file generated in step 8" -EffectedPartition "domain partition where you want to set the values"

 

For example:

 

Set-msExchArchiveInfo -EffectedMailboxCsvPath "C:\O365\EffectedMailboxes.csv" -EffectedPartition "DC=hckoffice365,DC=in"

 

**EffectedMailboxCsvPath – Location of CSV file generated in step 8. In my case its “C:\O365\EffectedMailboxes.csv”

 

**EffectedPartition (Not Mandatory) – Domain partition where you want to search and set the attributes. If you don’t mention this attribute, then script will take root partition by default.

 

  1. Once above steps completed force directory sync from AAD connect server PowerShell using below command.

 

Start-AdSyncSyncCycle -PolicyType Initial

 

  1. Once sync completed check office 365 portal after 10-15 mins and there should not be any error for effected mailboxes. You can also confirm by performing step 7 again and this time output CSV file should be blank.

 

Script File Zip file - Archive Guid Script

 

Please do share feedback in comments if you face any issues.

Thanks,

Harish Kaushal