Skip to content

Instantly share code, notes, and snippets.

@lwsrbrts
Created July 23, 2018 14:41
Show Gist options
  • Save lwsrbrts/b3d7e47531780b1de038addcd092fda1 to your computer and use it in GitHub Desktop.
Save lwsrbrts/b3d7e47531780b1de038addcd092fda1 to your computer and use it in GitHub Desktop.
A pester test to check domain controller replications, grouping by source DC. Obviously requires repadmin.
Describe 'Domain Controllers' {
Context 'Replication Link Status' {
$results = repadmin /showrepl * /csv | ConvertFrom-Csv # Get the results of all replications between all DCs
$groups = $results | Group-Object -Property 'Source DSA' # Group the results by the source DC
foreach ($sourcedsa in $groups) {
# Create a context for each source DC
Context "Source DSA = $($sourcedsa.Name)" {
$targets = $sourcedsa.Group # Assign the value of the groupings to another var since .Group doesn't implement IComparable
$targetdsa = $targets | Group-Object -Property 'Destination DSA' # Now group within this source DC by the destination DC (pulling naming contexts per source and destination together)
foreach ($target in $targetdsa ) {
# Create a context for each destination DSA
Context "Target DSA = $($target.Name)" {
foreach ($entry in $target.Group) {
# List out the results and check each naming context for failures
It "$($entry.'Naming Context') - should have zero replication failures" {
$entry.'Number of failures' | Should Be 0
}
}
}
}
}
}
}
}
@jkavanagh58
Copy link

Thanks... struggling to get Pester into the development process this just might help open some eyes beyond my simple computer tests

@jkavanagh58
Copy link

Curious why not Get-ADReplicationPartnerMetaData ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment