Skip to content

Instantly share code, notes, and snippets.

@CodeByAidan
Created August 7, 2024 13:29
Show Gist options
  • Save CodeByAidan/345c67ae17a17c50ebae34571c3226cb to your computer and use it in GitHub Desktop.
Save CodeByAidan/345c67ae17a17c50ebae34571c3226cb to your computer and use it in GitHub Desktop.
Remove duplicates entries from your path on windows, using PowerShell.
$semiColon = ';'
$pathArray = $env:PATH -split $semiColon
$uniquePathArray = $pathArray | Select-Object -Unique
$newPath = ($uniquePathArray -join $semiColon)
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::User)
# Verify changes using $env:PATH -split $semiColon | ForEach-Object { $_ }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment