#Requires -Version 5.1 <# .SYNOPSIS Uninstalls DupFinder from this workstation. #> $principal = [Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent() if (-not $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { Write-Error "This script must be run as Administrator." exit 1 } $ConfigFile = "C:\ProgramData\DupFinder\dupfinder.conf" $AppDir = "C:\ProgramData\DupFinder" $ShortcutPath = "$env:PUBLIC\Desktop\DupFinder.lnk" Write-Host "" Write-Host " DupFinder Uninstaller" -ForegroundColor Magenta Write-Host "" if (-not (Test-Path $ConfigFile)) { Write-Warning "DupFinder config not found. It may not be installed, or was already removed." exit 0 } # Read config $conf = @{} Get-Content $ConfigFile | ForEach-Object { if ($_ -match '^(.+?)=(.+)$') { $conf[$Matches[1]] = $Matches[2] } } $ComposeDir = $conf["COMPOSE_DIR"] $DataPath = $conf["DATA_PATH"] $ComposeYml = "$ComposeDir\docker-compose.yml" $OverrideYml = "$ComposeDir\docker-compose.override.yml" # ── Stop and remove container ───────────────────────────────────────────────── Write-Host "Stopping and removing container..." docker compose -f $ComposeYml -f $OverrideYml down 2>$null Write-Host " Done." # ── Remove Docker image? ────────────────────────────────────────────────────── $rmImage = Read-Host "Remove the DupFinder Docker image? Frees ~300-600 MB (Y/n)" if ($rmImage -ne 'n' -and $rmImage -ne 'N') { docker rmi dupfinder:latest 2>$null Write-Host " Image removed." } # ── Remove data directory? ──────────────────────────────────────────────────── Write-Host "" Write-Host "Data directory: $DataPath" Write-Host "This contains the scan database and all decisions." $rmData = Read-Host "Remove data directory? This CANNOT be undone. (y/N)" if ($rmData -eq 'y' -or $rmData -eq 'Y') { if (Test-Path $DataPath) { Remove-Item $DataPath -Recurse -Force Write-Host " Data directory removed." } } else { Write-Host " Data directory kept at: $DataPath" } # ── Remove shortcut ─────────────────────────────────────────────────────────── if (Test-Path $ShortcutPath) { Remove-Item $ShortcutPath -Force Write-Host "Desktop shortcut removed." } # ── Remove app directory ────────────────────────────────────────────────────── if (Test-Path $AppDir) { Remove-Item $AppDir -Recurse -Force Write-Host "App directory removed: $AppDir" } Write-Host "" Write-Host " DupFinder has been uninstalled." -ForegroundColor Green Write-Host ""