2020-06-11 16:15:23 +02:00
|
|
|
#!/snap/bin/powershell
|
2020-10-10 18:51:57 +02:00
|
|
|
|
2020-10-10 18:29:29 +02:00
|
|
|
# Syntax: ./train-dns-cache.ps1
|
2020-06-15 14:55:54 +02:00
|
|
|
# Description: trains the DNS cache with frequently used domain names
|
|
|
|
# Author: Markus Fleschutz
|
|
|
|
# Source: github.com/fleschutz/PowerShell
|
|
|
|
# License: CC0
|
2020-09-29 20:05:52 +02:00
|
|
|
|
2020-10-05 13:12:12 +02:00
|
|
|
try {
|
|
|
|
$StartTime = Get-Date
|
2020-11-01 12:11:15 +01:00
|
|
|
|
|
|
|
$Table = import-csv domain_table.csv
|
2020-10-05 13:12:12 +02:00
|
|
|
foreach($Row in $Table) {
|
|
|
|
$Domain = $Row.Domain
|
2020-11-06 15:30:14 +01:00
|
|
|
write-progress "Training DNS cache with $Domain..."
|
2020-10-05 13:12:12 +02:00
|
|
|
$Ignore = nslookup $Domain
|
|
|
|
}
|
2020-06-11 18:20:40 +02:00
|
|
|
|
2020-10-05 13:12:12 +02:00
|
|
|
$Count = $Table.Length
|
|
|
|
$StopTime = Get-Date
|
|
|
|
$TimeInterval = New-Timespan -start $StartTime -end $StopTime
|
2020-11-22 10:42:43 +01:00
|
|
|
write-host "OK - DNS cache trained with $Count domain names in $TimeInterval sec."
|
2020-10-05 13:12:12 +02:00
|
|
|
exit 0
|
|
|
|
} catch { Write-Error $Error[0] }
|
|
|
|
exit 1
|