-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheck_Domain_Response.ps1
More file actions
54 lines (47 loc) · 1.96 KB
/
Check_Domain_Response.ps1
File metadata and controls
54 lines (47 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Check_Domain_Response.ps1
# ---------------------------------------------
# This script helps troubleshoot Active Directory domain connectivity and DNS issues.
# It displays network DNS suffixes, prompts for a domain name, and runs:
# - nslookup for AD SRV records
# - nltest to get domain controller details
# ---------------------------------------------
# Display all network Connection-specific DNS Suffixes
$excludedSuffixes = @('lan', 'local', 'home', 'domain', 'corp', 'workgroup')
$dnsSuffixes = Get-DnsClient |
Where-Object { $_.ConnectionSpecificSuffix -and $_.ConnectionSpecificSuffix -ne "" } |
Select-Object -ExpandProperty ConnectionSpecificSuffix -Unique |
Where-Object { $_ -notin $excludedSuffixes }
if ($dnsSuffixes) {
Write-Host "Found Connection-specific DNS Suffix(es):" -ForegroundColor Green
foreach ($suffix in $dnsSuffixes) {
Write-Host (" - $suffix") -ForegroundColor Cyan
}
}
else {
Write-Host "No useful Connection-specific DNS Suffix found." -ForegroundColor Red
}
Write-Host "=========================================" -ForegroundColor Yellow
$DomainName = Read-Host -Prompt "Enter the domain name to check (e.g., ad.contoso.com)"
# Check if a domain name was provided
if ([string]::IsNullOrWhiteSpace($DomainName)) {
Write-Host "No domain name provided. Exiting..." -ForegroundColor Red
Start-Sleep -Seconds 3
exit
}
function Write-HorizontalLine {
Write-Host "=========================================" -ForegroundColor Yellow
}
# nslookup for SRV records
Write-HorizontalLine
Write-Host "Running nslookup for SRV records..." -ForegroundColor Cyan
Write-HorizontalLine
nslookup -type=SRV _ldap._tcp.dc._msdcs.$DomainName
# nltest to get domain controller info
Write-HorizontalLine
Write-Host "Running nltest to get domain controller details..." -ForegroundColor Cyan
Write-HorizontalLine
nltest /dsgetdc:$DomainName
Write-HorizontalLine
Write-Host "Domain check completed." -ForegroundColor Green
Write-HorizontalLine
pause