Resolve Repadmin Error 58: Map GUID to Domain Controller in Active Directory Forest
Active Directory replication errors can be tricky to troubleshoot—especially when you're faced with cryptic GUIDs like 2bd3eedd-fbc7-43c5-ab58-bc50f3dae0ab._msdcs.bbntechinfo.com
in repadmin /replsummary
output. These GUIDs represent domain controllers, but without a direct name reference, identifying the source of the issue becomes a challenge. In this post, I’ll walk you through a PowerShell-based approach to map these GUIDs to actual domain controller names across your entire forest. Whether you're dealing with error 58 or tracking down stale replication metadata, this method will help you pinpoint the problematic DC quickly and accurately—saving you time and frustration.
Below Powershell script will perform the check on each DC in the forest mentioned and return if the GUID matched with any of the DC. below script will work in Powershell 5.1
######################Script Starts#############################################
# Replace with your forest root domain
$forestRoot = "bbntechinofo.com"
$guidToFind = [guid]::Parse("replace here with your replication failing DC GUID")
# Create DirectoryContext for the forest
$context = New-Object System.DirectoryServices.ActiveDirectory.DirectoryContext("Forest", $forestRoot)
$forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetForest($context)
foreach ($domain in $forest.Domains) {
$domainName = $domain.Name
Write-Host "`n--- Searching domain: $domainName ---" -ForegroundColor Cyan
try {
$dcs = Get-ADDomainController -Server $domainName -Filter *
foreach ($dc in $dcs) {
try {
$computer = Get-ADComputer $dc.Name -Server $domainName
$dcGuid = $computer.ObjectGUID
if ($dcGuid -eq $guidToFind) {
Write-Host "`n✅ Match found!" -ForegroundColor Green
Write-Host "Domain : $domainName"
Write-Host "DC Name : $($dc.Name)"
Write-Host "DNS Hostname : $($dc.HostName)"
Write-Host "Site : $($dc.Site)"
return # Exit once match is found
} else {
Write-Host "Checked $($dc.Name) - No match" -ForegroundColor DarkGray
}
} catch {
Write-Warning "Could not retrieve computer object for $($dc.Name) in $domainName"
}
}
} catch {
Write-Warning "Failed to query domain controllers in $domainName"
}
}
Write-Host "`n❌ No match found for GUID $guidToFind in forest $forestRoot" -ForegroundColor Red
##################Script Ends ################################################
Out put example below
IF not Match it will re-turn like below
Checked DCname - No match
If match found means it will like below
✅ Match found!
Domain : bbntechinfo.com
DC Name : DCname
DNS Hostname : FQDN of the DC
Site : Which Particular Site.
How to Identify Domain Controllers from GUIDs in AD Replication Errors (Error 58)Resolve
Repadmin Error 58: Map GUID to Domain Controller in Active Directory Forest
PowerShell Script to Trace Domain Controller from GUID in AD Replication
FailuresTroubleshooting AD Replication Error 58: Find DC from GUID Across Forest
Active Directory Forest-Wide DC GUID Lookup for Repadmin Errors
Smart Way to Match GUID to Domain Controller in AD Using PowerShell
Fixing Replication Failures: Identify Orphaned or Stale DCs from GUIDs
Forest-Wide PowerShell Script to Resolve _msdcs GUID to Domain Controller
Step-by-Step Breakdown: How the Script Works
This PowerShell script helps Active Directory administrators identify which domain controller corresponds to a GUID seen in replication errors (like error 58 in repadmin /replsummary
). It performs a forest-wide search to match the GUID to a live domain controller.
🔹 Step 1: Define the GUID
Start by copying the GUID from your replication error and assigning it to the $guidToFind
variable. The script converts it to a [guid]
object for accurate comparison.
$guidToFind = [guid]::Parse("your-guid-here")
Step 2: Connect to the Forest
The script uses System.DirectoryServices.ActiveDirectory.DirectoryContext
to connect to the forest using its root domain name.
$context = New-Object System.DirectoryServices.ActiveDirectory.DirectoryContext("Forest", "bbeninfotech.com")
$forest = [System.DirectoryServices.ActiveDirectory.Forest]::GetForest($context)
Step 3: Enumerate All Domains
It loops through all domains in the forest using $forest.Domains
, ensuring no domain is missed.
🔹 Step 4: Query All Domain Controllers
For each domain, it uses Get-ADDomainController -Server <domain>
to list all DCs, then queries their corresponding computer objects to retrieve their ObjectGUID
.
🔹 Step 5: Match the GUID
Each DC’s GUID is compared to the target GUID. If a match is found, the script prints the DC’s name, DNS hostname, and site.
🔹 Step 6: Output Results
If no match is found, the script informs you that the GUID may belong to a decommissioned or unreachable DC.
Use Cases
- Troubleshooting replication errors like error 58.
- Identifying orphaned or stale DCs.
- Validating metadata cleanup after DC removal.
- Auditing forest-wide DC health.
Join the conversation