-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlancacheValidator.ps1
44 lines (34 loc) · 1.04 KB
/
lancacheValidator.ps1
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
# Put the IP of your lancache server here
$LANCACHE_IP = "192.168.1.141"
# We pull the domains right from the repo, we assume you've cloned uklans/cache-domains
# Check for updates to domain list
pushd ".\cache-domains"
git fetch
git pull
popd
# Get Lists
$List = Get-Content -Path ".\cache-domains\*.txt"
$List = $List | Where-Object {$_[0] -ne "#"}
foreach($domain in $List)
{
if($domain[0] -eq '*')
{
$domain = $domain.replace('*', 'a')
}
Write-Host -NoNewLine -ForegroundColor White "Lookup for $($domain)`tis`t"
$lookup = Resolve-DNSName -Name $domain
if($lookup.IPAddress -eq $LANCACHE_IP)
{
Write-Host -ForegroundColor Green "$($lookup.IPAddress)"
}
else {
Write-Host -ForegroundColor Red "$($lookup.IPAddress)"
}
# Optional sleep, just to keep from being overwhelmed by instant data.
Start-Sleep -Milliseconds 100
}
trap
{
# Catch "domain does not exist" errors
Write-Host -ForegroundColor Red "ERROR $($_)"
}