Skip to content

Instantly share code, notes, and snippets.

@tejashah88
Created November 14, 2024 11:09
Show Gist options
  • Save tejashah88/7239d1ac354d265e84cfd1791ed2fcda to your computer and use it in GitHub Desktop.
Save tejashah88/7239d1ac354d265e84cfd1791ed2fcda to your computer and use it in GitHub Desktop.
Mark all paths in Windows path variables (user & system) as existing (green) or non-existing (red). Used for when path variable exceeds 2047 characters.
# This script color-codes all paths within the user and system "Path" variables in Windows,
# mainly to handle when your path variables are deemed as too long (i.e. over 2047 characters
# long) and your uninstalled programs didn't properly clean up.
# Source: https://www.askwoody.com/forums/topic/clean-your-path/#post-2443639
Clear-Host
foreach ($path in ((get-childitem -path env:\path | Select -exp Value).split(";"))) {
if ($path -ne "") {
If (Test-Path $path) {
Write-host "True - $path" -ForegroundColor Green
} else {
Write-host "False - $path" -ForegroundColor Red
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment