Skip to content

Add Active Directory Replication Relationship Diagram#239

Merged
rebelinux merged 3 commits intodevfrom
copilot/add-replication-relationship-diagram
Mar 3, 2026
Merged

Add Active Directory Replication Relationship Diagram#239
rebelinux merged 3 commits intodevfrom
copilot/add-replication-relationship-diagram

Conversation

Copy link
Contributor

Copilot AI commented Mar 2, 2026

Adds a new Replication diagram type that visualizes AD replication topology — domain controllers grouped by site with directional edges labeled by transport protocol (IP/SMTP).

New files

  • Get-AbrADReplicationInfo.ps1 — Collects ADReplicationConnection objects across all forest domains, extracting FromServer/ToServer, site affiliation, transport protocol, and connection state
  • Get-AbrDiagReplication.ps1 — Builds the graph: DC nodes grouped into AD Site subgraphs, directed edges per replication connection, with an "Unknown Site" fallback subgraph for unresolvable site membership

Modified files

  • New-AbrADDiagram.ps1 — Adds 'Replication' to DiagramType ValidateSet, graph label switch, concentrate attribute (same as Sites), and dispatch branch calling Get-AbrDiagReplication
  • Get-AbrDiagrammer.ps1 — Adds 'Replication' to ValidateSet
  • AsBuiltReport.Microsoft.AD.json — Adds "Replication": true to DiagramType options (enabled by default)
  • Language/en-US/MicrosoftAD.psd1 / Language/es-ES/MicrosoftAD.psd1 — Adds replication-specific translation strings in English and Spanish
Original prompt

This section details on the original issue you should resolve

<issue_title>[Change Request]: Add a diagram about Replication relationship</issue_title>
<issue_description>### Description

Create a diagram showing the actice directory Replication and its relationships

Use diagrammer.core to create the diagramalso use the examples in the Example directory:
https://github.com/rebelinux/Diagrammer.Core/tree/dev/Examples

Additional Context

Use this diagram as an example:

https://raw.githubusercontent.com/rebelinux/IMG/refs/heads/main/active-directory-topology-diagrammer-14.png.webp

Before submitting

  • I have read the documentation, and referred to the known issues before submitting this change request.
  • I have checked for previously opened & closed issues before submitting this change request.</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: rebelinux <1002783+rebelinux@users.noreply.github.com>
Copilot AI changed the title [WIP] Add diagram for active directory replication relationship Add Active Directory Replication Relationship Diagram Mar 2, 2026
…treamline handling of unknown site affiliations
@github-actions
Copy link

github-actions bot commented Mar 3, 2026

PSScriptAnalyzer results:

Errors: [0], Warnings: [15], Information: [0]


RuleName   : PSReviewUnusedParameter
Severity   : Warning
ScriptName : Get-AbrADGPO.ps1
Line       : 20
Message    : The parameter 'ValidDCFromDomain' has been declared but not used.

RuleName   : PSReviewUnusedParameter
Severity   : Warning
ScriptName : Get-AbrADDomainObject.ps1
Line       : 19
Message    : The parameter 'ValidDcFromDomain' has been declared but not used.

RuleName   : PSReviewUnusedParameter
Severity   : Warning
ScriptName : Get-AbrADAuthenticationPolicy.ps1
Line       : 20
Message    : The parameter 'ValidDcFromDomain' has been declared but not used.

RuleName   : PSReviewUnusedParameter
Severity   : Warning
ScriptName : Get-AbrADTrust.ps1
Line       : 20
Message    : The parameter 'ValidDCFromDomain' has been declared but not used.

RuleName   : PSReviewUnusedParameter
Severity   : Warning
ScriptName : Get-AbrADCACRLSetting.ps1
Line       : 22
Message    : The parameter 'CA' has been declared but not used.

RuleName   : PSReviewUnusedParameter
Severity   : Warning
ScriptName : ConvertTo-ADObjectName.ps1
Line       : 21
Message    : The parameter 'DC' has been declared but not used.

RuleName   : PSReviewUnusedParameter
Severity   : Warning
ScriptName : Get-AbrADDomain.ps1
Line       : 20
Message    : The parameter 'ValidDcFromDomain' has been declared but not used.

RuleName   : PSReviewUnusedParameter
Severity   : Warning
ScriptName : Get-AbrADKerberosAudit.ps1
Line       : 20
Message    : The parameter 'ValidDCFromDomain' has been declared but not used.

RuleName   : PSReviewUnusedParameter
Severity   : Warning
ScriptName : Get-AbrADOU.ps1
Line       : 20
Message    : The parameter 'ValidDCFromDomain' has been declared but not used.

RuleName   : PSReviewUnusedParameter
Severity   : Warning
ScriptName : Get-ADObjectSearch.ps1
Line       : 21
Message    : The parameter 'Filter' has been declared but not used.

RuleName   : PSReviewUnusedParameter
Severity   : Warning
ScriptName : Get-ADObjectSearch.ps1
Line       : 22
Message    : The parameter 'Properties' has been declared but not used.

RuleName   : PSReviewUnusedParameter
Severity   : Warning
ScriptName : Get-ADObjectSearch.ps1
Line       : 23
Message    : The parameter 'SelectPrty' has been declared but not used.

RuleName   : PSReviewUnusedParameter
Severity   : Warning
ScriptName : ConvertTo-ADCanonicalName.ps1
Line       : 20
Message    : The parameter 'Domain' has been declared but not used.

RuleName   : PSReviewUnusedParameter
Severity   : Warning
ScriptName : Get-AbrADDFSHealth.ps1
Line       : 20
Message    : The parameter 'DCs' has been declared but not used.

RuleName   : PSReviewUnusedParameter
Severity   : Warning
ScriptName : Invoke-AsBuiltReport.Microsoft.AD.ps1
Line       : 21
Message    : The parameter 'Credential' has been declared but not used.

@rebelinux rebelinux marked this pull request as ready for review March 3, 2026 12:50
Copilot AI review requested due to automatic review settings March 3, 2026 12:50
@rebelinux rebelinux merged commit 72d10b8 into dev Mar 3, 2026
5 checks passed
@rebelinux rebelinux deleted the copilot/add-replication-relationship-diagram branch March 3, 2026 12:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Replication diagram type to visualize Active Directory replication topology (DCs grouped by site with protocol-labeled connections), and wires it into the existing diagram generation/config/translation pipeline.

Changes:

  • Introduces Get-AbrADReplicationInfo (data collection) and Get-AbrDiagReplication (graph construction) for replication topology.
  • Extends diagram entry points (New-AbrADDiagram, Get-AbrDiagrammer) and default config to support Replication.
  • Adds EN/ES translation strings for replication diagram labels/messages.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
Src/Private/New-AbrADDiagram.ps1 Adds Replication to diagram type validation, label selection, and dispatch to the new diagram function.
Src/Private/Get-AbrDiagrammer.ps1 Allows Replication as a selectable diagram type.
Src/Private/Get-AbrDiagReplication.ps1 New: builds the replication topology graph (sites as subgraphs, DC nodes, replication edges).
Src/Private/Get-AbrADReplicationInfo.ps1 New: collects replication connection data across domains/DCs for diagramming.
AsBuiltReport.Microsoft.AD.json Enables Replication diagrams by default in configuration.
Language/en-US/MicrosoftAD.psd1 Adds replication-related translation keys (EN).
Language/es-ES/MicrosoftAD.psd1 Adds replication-related translation keys (ES).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

$FromServer = try { ConvertTo-ADObjectName $Conn.ReplicateFromDirectoryServer.Split(',', 2)[1] -Session $DiagramTempPssSession -DC $System } catch { $Conn.ReplicateFromDirectoryServer.Split(',')[1] -replace 'CN=', '' }
$ToServer = try { ConvertTo-ADObjectName $Conn.ReplicateToDirectoryServer -Session $DiagramTempPssSession -DC $System } catch { $Conn.ReplicateToDirectoryServer -replace 'CN=NTDS Settings,CN=', '' -replace ',.*', '' }
$FromSite = try { $Conn.fromserver.Split(',')[3].SubString($Conn.fromserver.Split(',')[3].IndexOf('=') + 1) } catch { 'Unknown' }
$ToSite = try { $Conn.ReplicateToDirectoryServer.Split(',')[2].SubString($Conn.ReplicateToDirectoryServer.Split(',')[2].IndexOf('=') + 1) } catch { 'Unknown' }
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ToSite extraction uses Split(',')[2], which typically yields CN=Servers ("Servers") rather than the AD site name. This will mis-group DCs and color edges incorrectly; it should parse the same DN component as FromSite (usually index 3) or otherwise reliably resolve the site from the DN.

Suggested change
$ToSite = try { $Conn.ReplicateToDirectoryServer.Split(',')[2].SubString($Conn.ReplicateToDirectoryServer.Split(',')[2].IndexOf('=') + 1) } catch { 'Unknown' }
$ToSite = try { $Conn.ReplicateToDirectoryServer.Split(',')[3].SubString($Conn.ReplicateToDirectoryServer.Split(',')[3].IndexOf('=') + 1) } catch { 'Unknown' }

Copilot uses AI. Check for mistakes.
Comment on lines +33 to +34
$FromServer = try { ConvertTo-ADObjectName $Conn.ReplicateFromDirectoryServer.Split(',', 2)[1] -Session $DiagramTempPssSession -DC $System } catch { $Conn.ReplicateFromDirectoryServer.Split(',')[1] -replace 'CN=', '' }
$ToServer = try { ConvertTo-ADObjectName $Conn.ReplicateToDirectoryServer -Session $DiagramTempPssSession -DC $System } catch { $Conn.ReplicateToDirectoryServer -replace 'CN=NTDS Settings,CN=', '' -replace ',.*', '' }
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConvertTo-ADObjectName is called with -DC $System while iterating over per-domain/per-DC connections. This can resolve names against the wrong domain controller (or fail for other domains); consider using the current $DC.HostName (or a domain-specific valid DC) as the -DC argument, consistent with Get-AbrADSiteReplication.

Suggested change
$FromServer = try { ConvertTo-ADObjectName $Conn.ReplicateFromDirectoryServer.Split(',', 2)[1] -Session $DiagramTempPssSession -DC $System } catch { $Conn.ReplicateFromDirectoryServer.Split(',')[1] -replace 'CN=', '' }
$ToServer = try { ConvertTo-ADObjectName $Conn.ReplicateToDirectoryServer -Session $DiagramTempPssSession -DC $System } catch { $Conn.ReplicateToDirectoryServer -replace 'CN=NTDS Settings,CN=', '' -replace ',.*', '' }
$FromServer = try { ConvertTo-ADObjectName $Conn.ReplicateFromDirectoryServer.Split(',', 2)[1] -Session $DiagramTempPssSession -DC $DC.HostName } catch { $Conn.ReplicateFromDirectoryServer.Split(',')[1] -replace 'CN=', '' }
$ToServer = try { ConvertTo-ADObjectName $Conn.ReplicateToDirectoryServer -Session $DiagramTempPssSession -DC $DC.HostName } catch { $Conn.ReplicateToDirectoryServer -replace 'CN=NTDS Settings,CN=', '' -replace ',.*', '' }

Copilot uses AI. Check for mistakes.
} else {
$EdgeColor = 'darkblue'
}
Edge -From $FromNodeName -To $ToNodeName @{minlen = 2; label = $EdgeLabel; fontsize = 16; fontname = 'Segoe UI'; color = $EdgeColor; penwidth = 1.5 }
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replication edges are intended to be directional, but the diagram’s global edge defaults set dir = 'both' (and arrowtail = 'dot'), and this Edge call doesn’t override them. As a result replication connections will render with arrows at both ends; override edge attributes here (e.g., dir='forward' and an appropriate arrowtail/arrowhead) to make direction unambiguous.

Suggested change
Edge -From $FromNodeName -To $ToNodeName @{minlen = 2; label = $EdgeLabel; fontsize = 16; fontname = 'Segoe UI'; color = $EdgeColor; penwidth = 1.5 }
Edge -From $FromNodeName -To $ToNodeName @{minlen = 2; label = $EdgeLabel; fontsize = 16; fontname = 'Segoe UI'; color = $EdgeColor; penwidth = 1.5; dir = 'forward'; arrowhead = 'normal'; arrowtail = 'none' }

Copilot uses AI. Check for mistakes.
Comment on lines +153 to +154
connectingReplication = Recopilando informacion de replicacion de Microsoft AD desde {0}.
buildingReplication = Construyendo diagrama de replicacion de Microsoft AD desde {0}.
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spanish strings here omit accents ("informacion", "replicacion"), while earlier entries use accented forms. Consider updating to "Recopilando información de replicación de Microsoft AD desde {0}." for consistency/correctness.

Copilot uses AI. Check for mistakes.
connectingReplication = Recopilando informacion de replicacion de Microsoft AD desde {0}.
buildingReplication = Construyendo diagrama de replicacion de Microsoft AD desde {0}.
replTransportProtocol = Protocolo
replAutoGenerated = Generado automaticamente
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spanish value "Generado automaticamente" is missing the accent on "automáticamente"; consider correcting to "Generado automáticamente" for proper Spanish and consistency with other accented strings in this file.

Suggested change
replAutoGenerated = Generado automaticamente
replAutoGenerated = Generado automáticamente

Copilot uses AI. Check for mistakes.
Comment on lines +38 to +54
$AditionalInfo = [PSCustomObject] [ordered] @{
$reportTranslate.NewADDiagram.replTransportProtocol = $Conn.InterSiteTransportProtocol
$reportTranslate.NewADDiagram.replAutoGenerated = & {
if ($Conn.AutoGenerated) { $reportTranslate.NewADDiagram.replYes } else { $reportTranslate.NewADDiagram.replNo }
}
$reportTranslate.NewADDiagram.replEnabled = & {
if ($Conn.enabledConnection) { $reportTranslate.NewADDiagram.replYes } else { $reportTranslate.NewADDiagram.replNo }
}
}

$TempReplInfo = [PSCustomObject]@{
FromServer = $FromServer
ToServer = $ToServer
FromSite = $FromSite
ToSite = $ToSite
Domain = $Domain
AditionalInfo = $AditionalInfo
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$AditionalInfo/AditionalInfo is built and stored on each replication record but is never consumed by Get-AbrDiagReplication (nor elsewhere in this PR). Keeping it adds overhead and makes the data shape harder to reason about; either remove it or use it to enrich edge/node labels (e.g., enabled/autogenerated).

Suggested change
$AditionalInfo = [PSCustomObject] [ordered] @{
$reportTranslate.NewADDiagram.replTransportProtocol = $Conn.InterSiteTransportProtocol
$reportTranslate.NewADDiagram.replAutoGenerated = & {
if ($Conn.AutoGenerated) { $reportTranslate.NewADDiagram.replYes } else { $reportTranslate.NewADDiagram.replNo }
}
$reportTranslate.NewADDiagram.replEnabled = & {
if ($Conn.enabledConnection) { $reportTranslate.NewADDiagram.replYes } else { $reportTranslate.NewADDiagram.replNo }
}
}
$TempReplInfo = [PSCustomObject]@{
FromServer = $FromServer
ToServer = $ToServer
FromSite = $FromSite
ToSite = $ToSite
Domain = $Domain
AditionalInfo = $AditionalInfo
$TempReplInfo = [PSCustomObject]@{
FromServer = $FromServer
ToServer = $ToServer
FromSite = $FromSite
ToSite = $ToSite
Domain = $Domain

Copilot uses AI. Check for mistakes.
Comment on lines +541 to 545
} elseif ($DiagramType -eq 'Replication') {
if ($ReplInfo = Get-AbrDiagReplication | Select-String -Pattern '"([A-Z])\w+"\s\[label="";style="invis";shape="point";]' -NotMatch) {
$ReplInfo
} else { Write-Warning $reportTranslate.NewADDiagram.emptyReplication }
}
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description mentions enabling the Graphviz concentrate attribute for the Replication diagram (like Sites), but New-AbrADDiagram currently only sets concentrate when $DiagramType -eq 'Sites'. If Replication also needs edge concentration, extend that condition (or make it a per-diagram setting).

Copilot uses AI. Check for mistakes.
Comment on lines +150 to +158
replicationDiagramLabel = Topologia de replicacion de Active Directory
NoReplication = No hay topologia de replicacion
emptyReplication = No hay topologia de replicacion disponible para diagramar
connectingReplication = Recopilando informacion de replicacion de Microsoft AD desde {0}.
buildingReplication = Construyendo diagrama de replicacion de Microsoft AD desde {0}.
replTransportProtocol = Protocolo
replAutoGenerated = Generado automaticamente
replEnabled = Habilitado
replYes = Si
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spanish translation string is missing expected accents (the rest of the es-ES file uses accented forms like "información"). Consider correcting this label for proper Spanish: "Topología de replicación de Active Directory".

Suggested change
replicationDiagramLabel = Topologia de replicacion de Active Directory
NoReplication = No hay topologia de replicacion
emptyReplication = No hay topologia de replicacion disponible para diagramar
connectingReplication = Recopilando informacion de replicacion de Microsoft AD desde {0}.
buildingReplication = Construyendo diagrama de replicacion de Microsoft AD desde {0}.
replTransportProtocol = Protocolo
replAutoGenerated = Generado automaticamente
replEnabled = Habilitado
replYes = Si
replicationDiagramLabel = Topología de replicación de Active Directory
NoReplication = No hay topología de replicación
emptyReplication = No hay topología de replicación disponible para diagramar
connectingReplication = Recopilando información de replicación de Microsoft AD desde {0}.
buildingReplication = Construyendo diagrama de replicación de Microsoft AD desde {0}.
replTransportProtocol = Protocolo
replAutoGenerated = Generado automáticamente
replEnabled = Habilitado
replYes =

Copilot uses AI. Check for mistakes.
replTransportProtocol = Protocolo
replAutoGenerated = Generado automaticamente
replEnabled = Habilitado
replYes = Si
Copy link

Copilot AI Mar 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spanish value "Si" should be "Sí" (accent) in this context; the rest of the locale file already uses accented forms (e.g., "información").

Suggested change
replYes = Si
replYes =

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Change Request]: Add a diagram about Replication relationship

3 participants