Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Executing a Powershell Script to Sync Domain Controllers

jonathangilbert
Mega Sage

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
}
}
}

ps script.png

 

 

I have then created this action to then execute the above powershell script:-sync action.png

I have no inputs in thee action. When I test the action it errors with a "powershell execution error" and the logs show this 

jonathangilbert_0-1750682876352.png

jonathangilbert_1-1750682947016.png

 

It is the same connection that is used to update users and groups, but does anyone think it could be a permission issue?

0 REPLIES 0