Improve repadmin syncall targeting

This commit is contained in:
2026-01-29 10:58:41 +13:00
parent eaae091e36
commit cbcd364247

View File

@@ -238,6 +238,12 @@ function Invoke-Replication {
foreach ($server in $targets) {
$cmd = if ($Command -match "\{server\}") { $Command.Replace("{server}", $server) } else { $Command }
$cmd = $cmd.Trim()
if ($cmd -match "^(?i)\s*/repadmin\b") {
$cmd = $cmd -replace "^(?i)\s*/repadmin\b", "repadmin"
}
if ($server -and $cmd -match "(?i)\brepadmin\b" -and $cmd -match "(?i)\bsyncall\b" -and $cmd -notmatch "\{server\}") {
$cmd = $cmd -replace "(?i)\bsyncall\b", "syncall $server"
}
if ([string]::IsNullOrWhiteSpace($cmd)) { continue }
& $Log "Replication: $cmd"
& $env:ComSpec /c $cmd | ForEach-Object { & $Log $_ }
@@ -578,7 +584,7 @@ $y += 70 + $gap
Add-Label "Replication command ({server} optional)" $xLabel $y $labelWidth $rowHeight
$replicationCmdBox = Add-TextBox $xInput $y $inputWidth $rowHeight $false
$replicationCmdBox.Text = "repadmin /syncall {server} /A /e /P /d"
$replicationCmdBox.Text = "repadmin /syncall {server} /AdeP"
$y += $rowHeight + ($gap * 2)
Add-SectionHeader "ACME / Output"
@@ -948,6 +954,10 @@ $runBtn.Add_Click({
$replicationTargets = $selectedReplicationTargets
} else {
$replicationTargets = Split-List $replicationTargetsBox.Text
if ($replicationTargets.Count -eq 0 -and $dnsServer) {
$replicationTargets = @($dnsServer)
& $logAction "Replication targets empty; using primary DNS server $dnsServer."
}
}
Invoke-Replication -Servers $replicationTargets -Command $replicationCmdBox.Text -Log $logAction
} else {