Created
August 7, 2024 13:29
-
-
Save CodeByAidan/345c67ae17a17c50ebae34571c3226cb to your computer and use it in GitHub Desktop.
Remove duplicates entries from your path on windows, using PowerShell.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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