Skip to content

Commit 375ad53

Browse files
committed
(#2398) Restore PowerShell v2 support
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`.
1 parent 708a860 commit 375ad53

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/chocolatey.resources/helpers/functions/Install-ChocolateyInstallPackage.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ Start-ChocolateyProcessAsAdmin
249249
}
250250

251251
$installerTypeLower = $fileType.ToLower()
252-
if ($installerTypeLower -notin 'msi', 'exe', 'msu', 'msp') {
252+
if ('msi', 'exe', 'msu', 'msp' -notcontains $installerTypeLower) {
253253
Write-Warning "FileType '$fileType' is unrecognized, using 'exe' instead."
254254
$fileType = 'exe'
255255
}

src/chocolatey.resources/helpers/functions/Update-SessionEnvironment.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ None
6767

6868
#ordering is important here, $user should override $machine...
6969
$ScopeList = 'Process', 'Machine'
70-
if ($userName -notin 'SYSTEM', "${env:COMPUTERNAME}`$") {
70+
if ('SYSTEM', "${env:COMPUTERNAME}`$" -notcontains $userName) {
7171
# but only if not running as the SYSTEM/machine in which case user can be ignored.
7272
$ScopeList += 'User'
7373
}

0 commit comments

Comments
 (0)