View difference between Paste ID: g3T9GgGv and kZzafEPG
SHOW: | | - or go back to the newest paste.
1
##Set IP of your PiHole Here
2
$DNSSERVER = "192.168.2.4"
3
4
##Set IP of your bypass DNS Here
5
$BYPASSDNS = "8.8.8.8"
6
7
##Set how long to bypass PiHole in seconds
8
$STIME = "300"
9
10
##This part of the code limits the time the script window stays visible
11
$t = '[DllImport("user32.dll")] public static extern bool ShowWindow(int handle, int state);'
12
add-type -name win -member $t -namespace native
13
[native.win]::ShowWindow(([System.Diagnostics.Process]::GetCurrentProcess() | Get-Process).MainWindowHandle, 0)
14
15
##Get your interface where pihole DNS is in use
16
$iindex = Get-DnsClientServerAddress | where-object serveraddresses -eq $DNSSERVER | select-object -ExpandProperty interfaceindex
17
18
##Set your network to bypass
19
set-dnsclientserveraddress -InterfaceIndex $iindex -ServerAddresses $BYPASSDNS
20
21
##Wait time defined above
22
sleep $STIME
23
24
##Set your network back to default
25
Set-DnsClientServerAddress -InterfaceIndex $iindex -ResetServerAddresses
26
27
##Set your network back to PiHole DNS - Uncomment the next line if you static define your DNS
28
## Set-DnsClientServerAddress -InterfaceIndex $iindex -ServerAddresses $DNSSERVER