Skip to content

Instantly share code, notes, and snippets.

@joegasper
Last active August 23, 2016 01:56
Show Gist options
  • Save joegasper/fba411f9dad66460e3d96f63e9d164a2 to your computer and use it in GitHub Desktop.
Save joegasper/fba411f9dad66460e3d96f63e9d164a2 to your computer and use it in GitHub Desktop.
Time the replication of an Active Directory DNS record
#Requires -Version 4.0
#Create your record and then immediately run this script
$domainSuffix = '.my.domain.edu' #domain suffix for less typing
$client = 'dept-joe04' #client to query for on the DCs
$DNStype = 'CNAME' #type of DNS record to query
$DCs = @('dc-01','dc-02','dc-03','dc-04') #DCs to query against
$DClength = (-join $DCs).Length #for determining when all DCs have answered
$DCdone = '' #string that collects DC names as they answer
Write-Output "Checking $client at $(Get-Date)"
do {
foreach ($DC in $DCs) {
if ( $DCdone -notmatch $DC ) {
$check = Resolve-DnsName -Name $client$domainSuffix -Server $DC$domainSuffix -DnsOnly -Type $DNStype -ErrorAction SilentlyContinue
if (!$check.IPAddress -eq '') {
Write-Output "`t $DC answers `t $($check.IPAddress) at $(Get-Date)"
$DCdone += $DC
}
}
}
sleep 1
}
while ( $DCdone.Length -lt $DClength)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment