Last active
November 8, 2025 12:09
-
-
Save asheroto/fa216475272e58837b06c4be61088530 to your computer and use it in GitHub Desktop.
Revisions
-
asheroto renamed this gist
Feb 9, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
asheroto revised this gist
Jan 17, 2022 . 1 changed file with 10 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,4 +6,14 @@ The script is **NOT** lazy - it *actually* checks each environmental variable ** Enjoy! 😊️️❤ ## Install Note You can also install this script by typing... ``` Install-Script -Name Remove-DuplicatesFromPathVariables ``` As available on [PowerShell Gallery](https://www.powershellgallery.com/packages/Remove-DuplicatesFromPathVariables/0.0.1).  -
asheroto revised this gist
Jan 17, 2022 . No changes.There are no files selected for viewing
-
asheroto renamed this gist
Jan 17, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -24,7 +24,7 @@ $TempMachinePath # User PATH Write-Output "" Write-Output ("-" * 50) Write-Output "🧑 Checking User PATH 🧑" $TempUserPath = [System.Environment]::GetEnvironmentVariable("Path", "User"); $Dupes = ($TempUserPath.Split(";") | Group-Object | Where-Object { $_.Count -gt 1 }).Values; if ($Dupes.Count -gt 0) { $Dupes | ForEach-Object { $TempUserPath = $TempUserPath.Replace("$_;", ""); $TempUserPath += "$_;" }; [System.Environment]::SetEnvironmentVariable("Path", $TempUserPath, "User") } -
asheroto created this gist
Jan 17, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ # Remove Duplicate Entries from PATH Environmental Variables This PowerShell script will check the system PATH variable and the user PATH variable for duplicates and then remove any duplicates found. The script is **NOT** lazy - it *actually* checks each environmental variable **separately**, NOT simply `$ENV:PATH`. Enjoy! 😊️️❤  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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ Clear-Host; # Begin Write-Output "⏲️⏲️⏲️ Starting ⏲️⏲️⏲️" Write-Output ("-" * 50) Write-Output "" # System PATH Write-Output "🖥️ Checking System PATH 🖥️" $TempMachinePath = [System.Environment]::GetEnvironmentVariable("Path", "Machine"); $Dupes = ($TempMachinePath.Split(";") | Group-Object | Where-Object { $_.Count -gt 1 }).Values; if ($Dupes.Count -gt 0) { $Dupes | ForEach-Object { $TempMachinePath = $TempMachinePath.Replace("$_;", ""); $TempMachinePath += "$_;" }; [System.Environment]::SetEnvironmentVariable("Path", $TempMachinePath, "Machine") } Write-Output @" $("-" * 50) Found duplicates $("-" * 50) $Dupes $("-" * 50) Removing duplicates, result... $("-" * 50) $TempMachinePath "@; # User PATH Write-Output "" Write-Output ("-" * 50) Write-Output "🧑 Checking System PATH 🧑" $TempUserPath = [System.Environment]::GetEnvironmentVariable("Path", "User"); $Dupes = ($TempUserPath.Split(";") | Group-Object | Where-Object { $_.Count -gt 1 }).Values; if ($Dupes.Count -gt 0) { $Dupes | ForEach-Object { $TempUserPath = $TempUserPath.Replace("$_;", ""); $TempUserPath += "$_;" }; [System.Environment]::SetEnvironmentVariable("Path", $TempUserPath, "User") } Write-Output @" $("-" * 50) Found duplicates $("-" * 50) $Dupes $("-" * 50) Removing duplicates, result... $("-" * 50) $TempUserPath "@; # Complete Write-Output "" Write-Output ("-" * 50) Write-Output "✔️✔️✔️ Complete ✔️✔️✔️"