Skip to content

Instantly share code, notes, and snippets.

@opariffazman
Created May 31, 2020 06:46
Show Gist options
  • Save opariffazman/0327ba6c4f32b3ce4d9e98c4d8bb37f9 to your computer and use it in GitHub Desktop.
Save opariffazman/0327ba6c4f32b3ce4d9e98c4d8bb37f9 to your computer and use it in GitHub Desktop.
Simple pihole docker uninstall/update.
# 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