adding path cleanup utility Reset-PWSHSystemPath.ps1#6892
Merged
TravisEz13 merged 2 commits intoPowerShell:masterfrom May 22, 2018
Merged
adding path cleanup utility Reset-PWSHSystemPath.ps1#6892TravisEz13 merged 2 commits intoPowerShell:masterfrom
TravisEz13 merged 2 commits intoPowerShell:masterfrom
Conversation
TravisEz13
requested changes
May 21, 2018
Member
TravisEz13
left a comment
There was a problem hiding this comment.
please respond to comments
| $AssembledNewPath -split ';' | ||
| [Environment]::SetEnvironmentVariable("PATH",$AssembledNewPath,"$PathScopeItem") | ||
| } | ||
| } No newline at end of file |
Member
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*"}) |
Member
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) |
Member
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)" |
Member
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) |
Member
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.
TravisEz13
approved these changes
May 22, 2018
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