-
Notifications
You must be signed in to change notification settings - Fork 919
(#2398) Restore PowerShell v2 support #2411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
de7d1a8
to
71e84f9
Compare
This was initially in draft as I found the second commit while doing up the testing for it as I found it was still giving the error after fixing the first one. It's ready now. |
71e84f9
to
486192a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@corbob is there a reason you used |
@vexx32 that is a great question! |
Based on this: https://iannotes.wordpress.com/2011/12/25/powershell-comparison-operators/ They are equivalent, but it would be better to have them the same, right? |
Yep, they should be equivalent, but using different ones might confuse maintainers coming back to these code paths in the future. |
Oh duh. For some reason I was thinking |
PowerShell v2 doesn't recognize `-notin` as it was introduced in v3. This changes to use `-notcontains` which was introduced in v2 and works similar to `-notin`.
486192a
to
375ad53
Compare
There we go, should be updated now 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@corbob thanks for getting this fixed! |
Description Of Changes
Commit c408d12 introduced a change to fix a bug with the
$env:TEMP
variable. As well, commit f68a242 introduced handling of msps in the install helper.However, they both introduced PowerShell 3+ syntax. This changes those to work with PowerShell 2+.
Motivation and Context
We currently support PowerShell 2+, so it's important that the PowerShell uses v2 compatible commands.
What Have I Done To Test This
This one is specific to PowerShell 2 and the import of the
helpers\chocolateyInstaller.psm1
. It can be tested either on a Windows 7 with PowerShell 2 system (this is a multi-hour waiting game to build and update a system if you don't already have one), or on a newer Windows system with the PowerShell 2 compatibility feature enabled by runningpowershell -version 2
.From PowerShell 2 run:
Import-Module src\chocolatey.resources\helpers\chocolateyInstaller.psm1 -force
from the root of the repository. This should result in no errors and no output.Change Types Made
Related Issue
Fix #2398
Change Checklist