Executing a Powershell Script to Sync Domain Controllers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-23-2025 05:49 AM
Hi,
It has been requested that after adding a user to a group in AD, that a powershell script is then executed to sync all the domin controllers.
I have been supplied with this PS script:-
import-module activedirectory -warningaction "SilentlyContinue";
$domainControllers = Get-ADDomainController -Filter *
foreach ($sourceDC in $domainControllers) {
foreach ($targetDC in $domainControllers) {
if ($sourceDC.HostName -ne $targetDC.HostName) {
Write-Host "Forcing replication from $sourceDC to $targetDC"
repadmin /replicate $targetDC.HostName $sourceDC.HostName dc=yourdomain,dc=com
}
}
}
I have then created this action to then execute the above powershell script:-
I have no inputs in thee action. When I test the action it errors with a "powershell execution error" and the logs show this
It is the same connection that is used to update users and groups, but does anyone think it could be a permission issue?