Created
February 11, 2018 16:40
-
-
Save JaekelEDV/f5b920858516787f08f31ecdd1748d41 to your computer and use it in GitHub Desktop.
Powershell script checking for AD-relevant DNS Resource Records in DNS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#This script checks if all AD-relevant SRV-Records exist in DNS. Also it looks for netlogon.dns and the A-Record for the DC. | |
$Domain = (Get-ADDomain).DNSRoot | |
$DCName = (Get-ADDomainController).Name | |
$msdcs = (Get-DnsServerResourceRecord -ZoneName _msdcs.$Domain -RRType Srv) | |
$ARR = (Get-DnsServerResourceRecord -ZoneName $Domain -RRType A) | |
$PDC = [string] "_ldap._tcp.pdc" | |
$GC = [string] "_ldap._tcp.gc" | |
$KDC = [string] "_kerberos._tcp.dc" | |
$DC = [string] "_ldap._tcp.dc" | |
$A= [string] "$DCName" | |
$netlogon = [string] "$env:SystemRoot\System32\config\netlogon.dns" | |
#Checking if the netlog.dns file exists. | |
if | |
((Test-Path -Path $netlogon) -eq $true) | |
{ | |
Write-Host File netlogon.dns exists in $netlogon -ForegroundColor Green | |
} | |
else { | |
Write-Host File netlogon.dns does not exists in $netlogon -ForegroundColor Red | |
} | |
#Checking if A-Record for the DC exists. | |
if | |
($ARR.hostname -eq $A) | |
{ Write-Host -> A-Record for $DCName exists -ForegroundColor Green | |
} | |
else { | |
Write-Host -> A-Record for $DCName is missing -ForegroundColor Red | |
} | |
#Checking for the AD-relevant SRV-Records in _msdcs.$Domain | |
if | |
($msdcs.hostname -eq $KDC) | |
{ | |
Write-Host -> SRV-Record for KDC exists -ForegroundColor Green | |
} | |
else { | |
Write-Host -> SRV-Record for KDC is missing -ForegroundColor Red | |
} | |
if | |
($msdcs.hostname -eq $PDC) | |
{ | |
Write-Host -> SRV-Record for PDC exists -ForegroundColor Green | |
} | |
else { | |
Write-Host -> SRV-Record for PDC is missing -ForegroundColor Red | |
} | |
if | |
($msdcs.hostname -eq $GC) | |
{ Write-Host -> SRV-Record for GC exists -ForegroundColor Green | |
} | |
else { | |
Write-Host -> SRV-Record for GC is missing -ForegroundColor Red | |
} | |
if | |
($msdcs.hostname -eq $DC) | |
{ Write-Host -> SRV-Record for DC exists -ForegroundColor Green | |
} | |
else { | |
Write-Host -> SRV-Record for DC is missing -ForegroundColor Red | |
} | |
#Hints... | |
Write-Host If SRV-Records are missing you should restart the netlogon-Service. -ForegroundColor Yellow | |
Write-Host If the A-Record is missing you might try Register-DnsClient. -ForegroundColor Yellow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment