Created
May 31, 2020 06:46
-
-
Save opariffazman/0327ba6c4f32b3ce4d9e98c4d8bb37f9 to your computer and use it in GitHub Desktop.
Simple pihole docker uninstall/update.
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
# network variables | |
$enabledAdapter = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -filter "IPEnabled = $true" | ForEach-Object Description | |
$enabledAdapter | ForEach-Object { | |
Get-NetAdapter -InterfaceDescription $_ | |
} | |
do { | |
$interfaceAlias = Read-Host -Prompt "Enter your main NetAdapter Name (with Internet Access)" | |
try { | |
$adapterExist = Get-NetAdapter -InterfaceAlias $interfaceAlias -ErrorAction 'SilentlyContinue' | |
Write-Verbose -Message "$interfaceAlias Selected" -Verbose | |
} | |
catch { | |
Write-Warning -Message "NetAdapter with name $interfaceAlias not found" | |
} | |
} while (!$adapterExist) | |
# docker variables | |
$cmd = "docker.exe" | |
# stop, remove, prune | |
$prm = "stop pihole", "rm pihole", "image prune -a -f" | |
Write-Verbose -Message "Executing Docker Script for PiHole Uninstallation" -Verbose | |
$prm | ForEach-Object { | |
$dockerScript = $cmd + ' ' + $_ | |
try{ | |
Invoke-Expression $dockerScript -ErrorAction 'Stop' | |
}catch{ | |
Write-Error $PSItem | |
exit | |
} | |
} | |
Write-Verbose -Message "Pihole uninstalled completely, ready for fresh install" -Verbose | |
Write-Verbose -Message "Resetting this device DNS" -Verbose | |
Set-DnsClientServerAddress -InterfaceAlias $interfaceAlias -ResetServerAddresses |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment