Skip to content

Commit

Permalink
(chocolatey#2398) Restore PowerShell v2 support
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
corbob committed Oct 20, 2021
1 parent b288cd1 commit 71e84f9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ Start-ChocolateyProcessAsAdmin
}

$installerTypeLower = $fileType.ToLower()
if ($installerTypeLower -notin 'msi', 'exe', 'msu', 'msp') {
if ('msi', 'exe', 'msu', 'msp' -notcontains $installerTypeLower) {
Write-Warning "FileType '$fileType' is unrecognized, using 'exe' instead."
$fileType = 'exe'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ None

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

0 comments on commit 71e84f9

Please sign in to comment.