adding path cleanup utility Reset-PWSHSystemPath.ps1 - #6892
Merged
Travis Plunk (TravisEz13) merged 2 commits intoMay 22, 2018
Conversation
Darwin (DarwinJS)
requested review from
Travis Plunk (TravisEz13),
Aditya Patwardhan (adityapatwardhan) and
Dongbo Wang (daxian-dbw)
as code owners
May 18, 2018 00:51
Travis Plunk (TravisEz13)
requested changes
May 21, 2018
Travis Plunk (TravisEz13)
left a comment
Member
There was a problem hiding this comment.
please respond to comments
| $AssembledNewPath -split ';' | ||
| [Environment]::SetEnvironmentVariable("PATH",$AssembledNewPath,"$PathScopeItem") | ||
| } | ||
| } No newline at end of file |
There was a problem hiding this comment.
Add an ending newline, please?
| ForEach ($PathScopeItem in $PathScope) | ||
| { | ||
| $AssembledNewPath = $NewPath = '' | ||
| $pathstoremove = @([Environment]::GetEnvironmentVariable("PATH","$PathScopeItem").split(';') | Where { $_ -ilike "*\Program Files\Powershell\6*"}) |
There was a problem hiding this comment.
Add a comment like get all parts of the path that are like a powershell core path
| { | ||
| $AssembledNewPath = $NewPath = '' | ||
| $pathstoremove = @([Environment]::GetEnvironmentVariable("PATH","$PathScopeItem").split(';') | Where { $_ -ilike "*\Program Files\Powershell\6*"}) | ||
| If (!$RemoveAllOccurences) |
There was a problem hiding this comment.
add a comment like filter to all but the last instance, unless remove all occurrences is specified
| { | ||
| $pathstoremove = @($pathstoremove | sort-object | Select-Object -skiplast 1) | ||
| } | ||
| Write-Host "Reset-PWSHSystemPath: Found $($pathstoremove.count) paths to remove from $PathScopeItem path scope: $($Pathstoremove -join ', ' | out-string)" |
There was a problem hiding this comment.
Not blocking: The use of write-host could prevent the use of this script in automation. Write-verbose is prefered
| { | ||
| foreach ($path in [Environment]::GetEnvironmentVariable("PATH","$PathScopeItem").split(';')) | ||
| { | ||
| If ($Path) |
There was a problem hiding this comment.
even though PowerShell is not case sensitive, the best practice is to use the same case for the same variable.
Travis Plunk (TravisEz13)
approved these changes
May 22, 2018
Thatgfsj (Thatgfsj)
pushed a commit
to Thatgfsj-contribs/PowerShell
that referenced
this pull request
Aug 6, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Summary
Cleans up old powershell core paths
Addresses: #6811
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests