Script 1: Uninstall Debian WSL (Standalone)
Uninstall-DebianWSL.ps1
# ================================ # 💣 Uninstall WSL Debian + Clean Residual Files # ================================ Write-Host ”🔍 Checking installed WSL distributions…” -ForegroundColor Cyan wsl –list –verbose # Target distro name $targetDistro = ”Debian” # Confirm uninstall $confirm = Read-Host ”`nAre you sure you want to uninstall $targetDistro? This will permanently delete all data! (Type ’yes’ to confirm)” if ($confirm -ne ”yes”) { Write-Host ”❌ Operation cancelled.” -ForegroundColor Yellow exit } # Unregister distro Write-Host ”`n💥 Unregistering $targetDistro…” -ForegroundColor Red wsl –unregister $targetDistro Start-Sleep -Seconds 1 # Remove residual Appx packages Write-Host ”`n🧹 Removing Microsoft Store app remnants…” -ForegroundColor DarkGray Get-AppxPackage *debian* | Remove-AppxPackage -ErrorAction SilentlyContinue # Clean up file system paths $paths = @( ”$env:LOCALAPPDATAPackagesTheDebianProject*”, ”$env:USERPROFILE.wslconfig”, ”$env:USERPROFILE.wsl”, ”$env:APPDATAwsl” ) foreach ($path in $paths) { if (Test-Path $path) { Remove-Item $path -Recurse -Force -ErrorAction SilentlyContinue Write-Host ”🗑️ Deleted: $path” -ForegroundColor Green } } Write-Host ”`n✅ Debian has been fully uninstalled and cleaned.” -ForegroundColor Green
Script 2: Auto-Uninstall Debian + Ubuntu (Smart Detection)
Uninstall-WSL-Distros.ps1
# ================================ # 💣 Auto-detect & Uninstall Debian + Ubuntu from WSL # ================================ # Get installed WSL distros $distros = wsl –list –quiet # Define targets $targets = @(”Debian”, ”Ubuntu”) # Filter matches $matchedDistros = $distros | Where-Object { $targets -contains $_ } if ($matchedDistros.Count -eq 0) { Write-Host ”⚠️ No Debian or Ubuntu distributions found. Nothing to uninstall.” -ForegroundColor Yellow exit } Write-Host ”`nThe following WSL distributions will be removed:” -ForegroundColor Cyan $matchedDistros | ForEach-Object { Write-Host ” - $_” } # Confirm uninstall $confirm = Read-Host ”`n⚠️ Are you sure you want to uninstall these distributions? This will permanently delete all data! (Type ’yes’ to confirm)” if ($confirm -ne ”yes”) { Write-Host ”❌ Operation cancelled.” -ForegroundColor DarkYellow exit } # Uninstall each foreach ($distro in $matchedDistros) { Write-Host ”`n💥 Unregistering: $distro” -ForegroundColor Red wsl –unregister $distro Start-Sleep -Seconds 1 } # Remove Appx packages Write-Host ”`n🧹 Cleaning up Microsoft Store packages…” -ForegroundColor DarkGray Get-AppxPackage *debian* | Remove-AppxPackage -ErrorAction SilentlyContinue Get-AppxPackage *ubuntu* | Remove-AppxPackage -ErrorAction SilentlyContinue # Remove leftover directories $paths = @( ”$env:LOCALAPPDATAPackagesTheDebianProject*”, ”$env:LOCALAPPDATAPackagesCanonicalGroupLimited*”, ”$env:USERPROFILE.wslconfig”, ”$env:USERPROFILE.wsl”, ”$env:APPDATAwsl” ) foreach ($path in $paths) { if (Test-Path $path) { Remove-Item $path -Recurse -Force -ErrorAction SilentlyContinue Write-Host ”🗑️ Deleted: $path” -ForegroundColor Green } } Write-Host ”`n✅ Selected WSL distributions have been fully uninstalled and cleaned.” -ForegroundColor Green
How to Use (Both Scripts)
1.Save as .ps1 files (e.g. Uninstall-WSL-Distros.ps1)
2.Open PowerShell as Administrator
3.Run this to allow script execution (if not already enabled):
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
4.Run the script:
.Uninstall-WSL-Distros.ps1
OVER!