O365Synchronizer is a PowerShell module that allows you to synchronize users/contacts to user mailboxes contact list. It can also be used to synchronize users between tenants as contacts or guests.
- Synchronize Users between tenants as Guests
- ✅ Synchronize Users between tenants as Contacts (organization contacts)
- ✅ Add
- ✅ Update
- ✅ Remove
- ✅ Synchronize GAL (Users & Contacts) to user mailbox (personal contacts)
- ✅ Add
- ✅ Update
- ✅ Remove
- Backup current contacts
- ✅ Remove current personal contacts
- ✅ Remove current personal "synchronized" contacts
Installation doesn't require administrative rights. You can install it using following:
Install-Module O365Synchronizer
But if you don't have administrative rights on your machine:
Install-Module O365Synchronizer -Scope CurrentUser
To update
Update-Module -Name O365Synchronizer
That's it. Whenever there's a new version you simply run the command and you can enjoy it. Remember, that you may need to close, reopen the PowerShell session if you have already used the module before updating it. The important thing is if something works for you on production, keep using it till you test the new version on a test computer. I do changes that may not be big, but big enough that auto-update will break your code. For example, small rename to a parameter and your code stops working! Be responsible!
If you want to contribute to the module, you can clone the repository and use it as a module, but you will need those to be installed:
$Modules = @(
'PSSharedGoods'
#'Mailozaurr'
#'PSWriteHTML'
'PSWriteColor'
)
$ModulesGraph = @(
'Microsoft.Graph.Identity.SignIns'
'Microsoft.Graph.Identity.DirectoryManagement'
'Microsoft.Graph.Users'
'Microsoft.Graph.PersonalContacts'
'Microsoft.Graph.Authentication'
)
foreach ($Module in $Modules) {
Install-Module -Name $Module -Force -Scope CurrentUser -Verbose
}
# Graph modules, which can be used with prerlease versions
foreach ($Module in $ModulesGraph) {
Install-Module -Name $Module -Force -Scope CurrentUser -AllowPrerelease -Verbose
}
Before being able to synchronize GAL to users contact list you need to create application in O365 with following permissions:
User.Read.All
- to read usersOrgContact.Read.All
- to read contactsContacts.ReadWrite
- to write contacts
Import-Module O365Synchronizer
$ClientID = '9e1b3'
$TenantID = 'ceb371'
$ClientSecret = 'nQF8'
$Credentials = [pscredential]::new($ClientID, (ConvertTo-SecureString $ClientSecret -AsPlainText -Force))
Connect-MgGraph -ClientSecretCredential $Credentials -TenantId $TenantID -NoWelcome
# Synchronization per user or multiple users in one
Sync-O365PersonalContact -UserId 'przemyslaw.klys@test.pl', 'adam.klys@test.pl' -Verbose -MemberTypes 'Contact', 'Member' -GuidPrefix 'O365Synchronizer' | Format-Table *
Source tenant:
User.Read.All
- to read users
Target tenant:
Exchange.ManageAsApp
- to read/write contacts in Exchange (remember to add application toExchange Recipient Administrator
role)
To synchronize users/contacts from Source tenant to Destination tenant you can do it in following way:
# Source Tenant
$ClientID = '9e1b3c36'
$TenantID = 'ceb371f6'
$ClientSecret = 'NDE'
$Credentials = [pscredential]::new($ClientID, (ConvertTo-SecureString $ClientSecret -AsPlainText -Force))
Connect-MgGraph -ClientSecretCredential $Credentials -TenantId $TenantID -NoWelcome
# do the filtering of any kind on UsersToSync to get the users you want to synchronize
$UsersToSync = Get-MgUser | Select-Object -First 10
# Destination tenant - you need to create application with permissions to read/write contacts in Exchange
$ClientID = 'edc4302e'
Connect-ExchangeOnline -AppId $ClientID -CertificateThumbprint '2E' -Organization 'xxxxx.onmicrosoft.com'
Sync-O365Contact -SourceObjects $UsersToSync -Domains 'evotec.pl','gmail.com' -Verbose -WhatIf
You can revert the order and set it up to synchronize from Destination tenant to Source tenant to have a two-way synchronization.