Synchronizing OUs with GALSync On-Prem
Configure GALSync to sync specific organizational units instead of the entire domain.
Overview
By default, GALSync synchronizes all mail-enabled users in your domain. However, you may need to limit synchronization to specific organizational units (OUs). This requires modifying the PullUsers.ps1 PowerShell script.
Prerequisites
- • Working PowerShell knowledge required
- • Administrative access to the GALSync server
- • Cloudiway GALSync agent already installed
Initial Setup Assistance
File Location
The script file to modify is located at:
C:\Program Files (x86)\Cloudiway\GalSync LocalAgent\PullUsers.ps1
Open this file in a text editor with administrator privileges.
Single OU Configuration
Modifying the Script
Locate the Get-MailUser PowerShell
command within the script and add the -OrganizationalUnit
parameter.
Parameter Format
-OrganizationalUnit "OU=User Accounts 1,OU=Company Users,DC=domain,DC=com"
Example
To sync only users from the "Sales" OU in contoso.com:
Get-MailUser -OrganizationalUnit "OU=Sales,OU=Users,DC=contoso,DC=com"
Multiple OUs Configuration
Synchronizing Multiple OUs
When synchronizing multiple organizational units, each command should be placed
on separate lines with the -Append
parameter to prevent overwriting the export file.
Multiple OU Example
# First OU (creates file) Get-MailUser -OrganizationalUnit "OU=Sales,DC=contoso,DC=com" | Export-Csv users.csv # Second OU (appends to file) Get-MailUser -OrganizationalUnit "OU=Marketing,DC=contoso,DC=com" | Export-Csv users.csv -Append # Third OU (appends to file) Get-MailUser -OrganizationalUnit "OU=Engineering,DC=contoso,DC=com" | Export-Csv users.csv -Append
Important
-Append parameter is critical for subsequent OUs. Without it,
each command would overwrite the previous export, resulting in only the last
OU being synchronized.
After Modification
- 1. Save the modified PullUsers.ps1 file
- 2. Test the script manually to verify output
- 3. Restart the GALSync agent if running
- 4. Monitor synchronization in the Cloudiway dashboard
Screenshots