Skip to content

Instantly share code, notes, and snippets.

@jpluimers
Last active September 18, 2021 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpluimers/7aed9b9feb05b6a22a6e2103c234b24f to your computer and use it in GitHub Desktop.
Save jpluimers/7aed9b9feb05b6a22a6e2103c234b24f to your computer and use it in GitHub Desktop.
Windows 7 with PowerShell v2 fails to upgrade to PowerShell v3 through chocolatey: `You must provide a value expression on the right-hand side of the '-' operator.`

ContactOwners

Failure

Sumitting through https://community.chocolatey.org/packages/PowerShell/ContactOwners, even in an anonymous browser window, got me

reCAPTCHA Error(s): Suspicious behavior detected. Sometimes this misidentifies legitimate requests. If this request is legitimate, please visit our Gitter channel to reach out to our team." even in an anonymous browser window.

reCAPTCHA Error

Message

To: Mark.Michaelis, DarwinJS

Hi Mark, Darwin,

I know that on Windows 7 with stock PowerShell 2.0, errors like "You must provide a value expression on the right-hand side of the '-' operator." can happen with individual packages.

In the past, the solution was to install https://community.chocolatey.org/packages/PowerShell/3.0.20121027 using choco upgrade --yes powershell --version=3.0.20121027

That currently fails with the same error, despite the requirements at https://docs.chocolatey.org/en-us/choco/setup#requirements

Windows 7+ / Windows Server 2003+ PowerShell v2+ (Not PowerShell Core yet though)(minimum is v3 for install from this website due to TLS 1.2 requirement) .NET Framework 4+ (the installation will attempt to install .NET 4.0 if you do not have it installed) (minimum is 4.5 for install from this website due to TLS 1.2 requirement)

The full log of choco upgrade --yes powershell --version=3.0.20121027 --debug --verbose: is at https://gist.github.com/jpluimers/7aed9b9feb05b6a22a6e2103c234b24f

Replacing upgrade by install and running choco install --yes powershell --version=3.0.20121027 --debug --verbose gives the same error.

I found, https://github.com/DarwinJS/ChocoPackages/tree/master/PowerShell, which points to https://gitlab.com/DarwinJS/ChocoPackages/tree/master/openssh, then found https://gitlab.com/DarwinJS/ChocoPackages/-/tree/master/PowerShell and the script at https://gitlab.com/DarwinJS/ChocoPackages/-/blob/master/PowerShell/v3.0/tools/ChocolateyInstall.ps1

That one does not seem to have suspicious operators like -in which are unavailable to PowerShell v2.

My current condition (still recovering from extensive rectum cancer treatment) isn't well enough to do the same for https://github.com/chocolatey/choco/blob/master/src/chocolatey.resources/helpers/chocolateyInstaller.psm1 and all files under https://github.com/chocolatey/choco/tree/master/src/chocolatey.resources/helpers/functions

Can you please try to help me out on this one?

What is the suggested way to still upgrade to PowerShell v3 on Windows 7?

Regards,

--jeroen

2021-09-15 19:49:29,735 4164 [DEBUG] - XmlConfiguration is now operational
2021-09-15 19:49:29,798 4164 [INFO ] - ============================================================
2021-09-15 19:49:30,001 4164 [INFO ] - Chocolatey v0.11.1
2021-09-15 19:49:30,017 4164 [DEBUG] - Chocolatey is running on Windows v 6.1.7601.65536
2021-09-15 19:49:30,017 4164 [DEBUG] - Attempting to delete file "C:/ProgramData/chocolatey/choco.exe.old".
2021-09-15 19:49:30,017 4164 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\choco.exe.old".
2021-09-15 19:49:30,032 4164 [DEBUG] - Command line: "C:\ProgramData\chocolatey\choco.exe" upgrade --yes powershell --version=3.0.20121027 --debug --verbose
2021-09-15 19:49:30,032 4164 [DEBUG] - Received arguments: upgrade --yes powershell --version=3.0.20121027 --debug --verbose
2021-09-15 19:49:30,095 4164 [DEBUG] - RemovePendingPackagesTask is now ready and waiting for PreRunMessage.
2021-09-15 19:49:30,095 4164 [DEBUG] - Sending message 'PreRunMessage' out if there are subscribers...
2021-09-15 19:49:30,110 4164 [DEBUG] - [Pending] Removing all pending packages that should not be considered installed...
2021-09-15 19:49:30,173 4164 [DEBUG] - Performing validation checks.
2021-09-15 19:49:30,173 4164 [DEBUG] - Global Configuration Validation Checks:
2021-09-15 19:49:30,173 4164 [DEBUG] - - Package Exit Code / Exit On Reboot = Checked
2021-09-15 19:49:30,188 4164 [DEBUG] - System State Validation Checks:
2021-09-15 19:49:30,188 4164 [DEBUG] - Reboot Requirement Checks:
2021-09-15 19:49:30,188 4164 [DEBUG] - - Pending Computer Rename = Checked
2021-09-15 19:49:30,188 4164 [DEBUG] - - Pending Component Based Servicing = Checked
2021-09-15 19:49:30,188 4164 [DEBUG] - - Pending Windows Auto Update = Checked
2021-09-15 19:49:30,188 4164 [DEBUG] - - Pending File Rename Operations = Ignored
2021-09-15 19:49:30,204 4164 [DEBUG] - - Pending Windows Package Installer = Checked
2021-09-15 19:49:30,204 4164 [DEBUG] - - Pending Windows Package Installer SysWow64 = Checked
2021-09-15 19:49:30,204 4164 [INFO ] - 2 validations performed. 2 success(es), 0 warning(s), and 0 error(s).
2021-09-15 19:49:30,204 4164 [DEBUG] - The source 'https://chocolatey.org/api/v2/' evaluated to a 'normal' source type
2021-09-15 19:49:30,220 4164 [DEBUG] -
NOTE: Hiding sensitive configuration data! Please double and triple
check to be sure no sensitive data is shown, especially if copying
output to a gist for review.
2021-09-15 19:49:30,220 4164 [DEBUG] - Configuration: CommandName='upgrade'|
CacheLocation='C:\Users\jeroenp\AppData\Local\Temp\chocolatey'|
ContainsLegacyPackageInstalls='True'|
CommandExecutionTimeoutSeconds='2700'|WebRequestTimeoutSeconds='30'|
Sources='https://chocolatey.org/api/v2/'|SourceType='normal'|
Debug='True'|Verbose='True'|Trace='False'|Force='False'|Noop='False'|
HelpRequested='False'|UnsuccessfulParsing='False'|RegularOutput='True'|
QuietOutput='False'|PromptForConfirmation='False'|AcceptLicense='True'|
AllowUnofficialBuild='False'|Input='powershell'|Version='3.0.20121027'|
AllVersions='False'|SkipPackageInstallProvider='False'|
PackageNames='powershell'|Prerelease='False'|ForceX86='False'|
OverrideArguments='False'|NotSilent='False'|
ApplyPackageParametersToDependencies='False'|
ApplyInstallArgumentsToDependencies='False'|IgnoreDependencies='False'|
AllowMultipleVersions='False'|AllowDowngrade='False'|
ForceDependencies='False'|Information.PlatformType='Windows'|
Information.PlatformVersion='6.1.7601.65536'|
Information.PlatformName='Windows 7'|
Information.ChocolateyVersion='0.11.1.0'|
Information.ChocolateyProductVersion='0.11.1'|
Information.FullName='choco, Version=0.11.1.0, Culture=neutral, PublicKeyToken=79d02ea9cad655eb'|
Information.Is64BitOperatingSystem='True'|
Information.Is64BitProcess='True'|Information.IsInteractive='True'|
Information.UserName='jeroenp'|Information.UserDomainName='win7vm'|
Information.IsUserAdministrator='True'|
Information.IsUserSystemAccount='False'|
Information.IsUserRemoteDesktop='False'|
Information.IsUserRemote='True'|
Information.IsProcessElevated='True'|
Information.IsLicensedVersion='False'|Information.LicenseType='Foss'|
Information.CurrentDirectory='C:\bin\bin'|
Features.AutoUninstaller='True'|Features.ChecksumFiles='True'|
Features.AllowEmptyChecksums='False'|
Features.AllowEmptyChecksumsSecure='True'|
Features.FailOnAutoUninstaller='False'|
Features.FailOnStandardError='False'|Features.UsePowerShellHost='True'|
Features.LogEnvironmentValues='False'|Features.LogWithoutColor='False'|
Features.VirusCheck='False'|
Features.FailOnInvalidOrMissingLicense='False'|
Features.IgnoreInvalidOptionsSwitches='True'|
Features.UsePackageExitCodes='True'|
Features.UseEnhancedExitCodes='False'|
Features.UseFipsCompliantChecksums='False'|
Features.ShowNonElevatedWarnings='True'|
Features.ShowDownloadProgress='True'|
Features.StopOnFirstPackageFailure='False'|
Features.UseRememberedArgumentsForUpgrades='False'|
Features.IgnoreUnfoundPackagesOnUpgradeOutdated='False'|
Features.SkipPackageUpgradesWhenNotInstalled='False'|
Features.RemovePackageInformationOnUninstall='False'|
Features.ExitOnRebootDetected='False'|
Features.LogValidationResultsOnWarnings='True'|
Features.UsePackageRepositoryOptimizations='True'|
Features.ScriptsCheckLastExitCode='False'|
ListCommand.LocalOnly='False'|
ListCommand.IdOnly='False'|ListCommand.IncludeRegistryPrograms='False'|
ListCommand.PageSize='25'|ListCommand.Exact='False'|
ListCommand.ByIdOnly='False'|ListCommand.ByTagOnly='False'|
ListCommand.IdStartsWith='False'|ListCommand.OrderByPopularity='False'|
ListCommand.ApprovedOnly='False'|
ListCommand.DownloadCacheAvailable='False'|
ListCommand.NotBroken='False'|
ListCommand.IncludeVersionOverrides='False'|
UpgradeCommand.FailOnUnfound='False'|
UpgradeCommand.FailOnNotInstalled='False'|
UpgradeCommand.NotifyOnlyAvailableUpgrades='False'|
UpgradeCommand.ExcludePrerelease='False'|
NewCommand.AutomaticPackage='False'|
NewCommand.UseOriginalTemplate='False'|SourceCommand.Command='unknown'|
SourceCommand.Priority='0'|SourceCommand.BypassProxy='False'|
SourceCommand.AllowSelfService='False'|
SourceCommand.VisibleToAdminsOnly='False'|
FeatureCommand.Command='unknown'|ConfigCommand.Command='unknown'|
ApiKeyCommand.Remove='False'|PinCommand.Command='unknown'|
OutdatedCommand.IgnorePinned='False'|
ExportCommand.IncludeVersionNumbers='False'|Proxy.BypassOnLocal='True'|
2021-09-15 19:49:30,267 4164 [DEBUG] - _ Chocolatey:ChocolateyUpgradeCommand - Normal Run Mode _
2021-09-15 19:49:30,282 4164 [INFO ] - Upgrading the following packages:
2021-09-15 19:49:30,282 4164 [INFO ] - powershell
2021-09-15 19:49:30,282 4164 [INFO ] - By upgrading, you accept licenses for the packages.
2021-09-15 19:49:30,392 4164 [WARN ] - powershell is not installed. Installing...
2021-09-15 19:49:32,329 4164 [INFO ] - [NuGet] Installing 'PowerShell 3.0.20121027'.
2021-09-15 19:49:32,345 4164 [DEBUG] - [NuGet] Added file 'ChocolateyInstall.ps1' to folder 'PowerShell'.
2021-09-15 19:49:32,345 4164 [DEBUG] - [NuGet] Added file 'PowerShell.nupkg' to folder 'PowerShell'.
2021-09-15 19:49:32,595 4164 [DEBUG] - [NuGet] Added file 'PowerShell.nuspec' to folder 'PowerShell'.
2021-09-15 19:49:32,595 4164 [INFO ] - [NuGet] Successfully installed 'PowerShell 3.0.20121027'.
2021-09-15 19:49:32,595 4164 [INFO ] -
PowerShell v3.0.20121027
2021-09-15 19:49:32,610 4164 [INFO ] - powershell package files upgrade completed. Performing other installation steps.
2021-09-15 19:49:32,673 4164 [DEBUG] - Setting installer args for PowerShell
2021-09-15 19:49:32,673 4164 [DEBUG] - Setting package parameters for PowerShell
2021-09-15 19:49:32,688 4164 [DEBUG] - Contents of 'C:\ProgramData\chocolatey\lib\PowerShell\ChocolateyInstall.ps1':
2021-09-15 19:49:32,688 4164 [DEBUG] - try
{
[string] $packageName="PowerShell 3.0"
[string] $fileType="exe"
[string] $silentArgs="/quiet /norestart /log:`"$env:TEMP\PowerShell.v3.Install.log`""
[string] $url = "http://download.microsoft.com/download/E/7/6/E76850B8-DA6E-4FF5-8CCE-A24FC513FD16/Windows6.1-KB2506143-x86.msu"
[string] $url64bit = "http://download.microsoft.com/download/E/7/6/E76850B8-DA6E-4FF5-8CCE-A24FC513FD16/Windows6.1-KB2506143-x64.msu"
[string[]] $validExitCodes = @(0, 3010) # 2359302 occurs if the package is already installed.
[string] $wusaExe="wusa.exe"
if ($PSVersionTable -and ($PSVersionTable.PSVersion -ge [Version]'3.0'))
{
Write-ChocolateySuccess "$packageName already installed on your OS"
return
}
$osVersion = [Environment]::OSVersion.Version
if ($osVersion -lt [Version]'6.0')
{
Write-ChocolateyFailure $packageName "$packageName not supported on your OS"
return
}
elseif ($osVersion -lt [Version]'6.1')
{
$url = 'http://download.microsoft.com/download/E/7/6/E76850B8-DA6E-4FF5-8CCE-A24FC513FD16/Windows6.0-KB2506146-x86.msu'
$url64bit = 'http://download.microsoft.com/download/E/7/6/E76850B8-DA6E-4FF5-8CCE-A24FC513FD16/Windows6.0-KB2506146-x64.msu'
}
$chocTempDir = Join-Path $env:TEMP "chocolatey"
$tempDir = Join-Path $chocTempDir "$packageName(RTM)"
if (![System.IO.Directory]::Exists($tempDir))
{
[System.IO.Directory]::CreateDirectory($tempDir)
}
$file = Join-Path $tempDir "$($packageName) Install.$fileType"
if(!(test-path $file))
{
Get-ChocolateyWebFile $packageName $file $url $url64bit
}
$silentArgs="`"$file`" $silentArgs"
Install-ChocolateyInstallPackage $packageName $fileType $silentArgs $wusaExe -validExitCodes $validExitCodes
Write-Warning "$packageName requires a reboot to complete the installation."
Write-ChocolateySuccess $packageName
}
catch
{
Write-ChocolateyFailure $packageName $($_.Exception.Message)
}
2021-09-15 19:49:32,751 4164 [DEBUG] - Calling built-in PowerShell host with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1'; & 'C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1' -packageScript 'C:\ProgramData\chocolatey\lib\PowerShell\ChocolateyInstall.ps1' -installArguments '' -packageParameters ''']
2021-09-15 19:49:32,767 4164 [DEBUG] - Redirecting System.Management.Automation.resources, Version=1.0.0.0, Culture=en-US, PublicKeyToken=31bf3856ad364e35, requested by ''
2021-09-15 19:49:34,188 4164 [DEBUG] - Host version is 2.0, PowerShell Version is '2.0' and CLR Version is '4.0.30319.42000'.
2021-09-15 19:49:34,392 4164 [ERROR] - You must provide a value expression on the right-hand side of the '-' operator.
2021-09-15 19:49:34,392 4164 [ERROR] - The specified module 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1' was not loaded because no valid module file was found in any module directory.
2021-09-15 19:49:34,407 4164 [DEBUG] - ---------------------------Script Execution---------------------------
2021-09-15 19:49:34,407 4164 [DEBUG] - Running 'ChocolateyScriptRunner' for PowerShell v3.0.20121027 with packageScript 'C:\ProgramData\chocolatey\lib\PowerShell\ChocolateyInstall.ps1', packageFolder:'C:\ProgramData\chocolatey\lib\PowerShell', installArguments: '', packageParameters: '',
2021-09-15 19:49:34,423 4164 [DEBUG] - Running 'C:\ProgramData\chocolatey\lib\PowerShell\ChocolateyInstall.ps1'
2021-09-15 19:49:34,485 4164 [ERROR] - ERROR: The term 'Write-ChocolateyFailure' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin)
at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)
at System.Management.Automation.ExecutionContext.CreateCommand(String command)
at System.Management.Automation.CommandNode.CreateCommandProcessor(Int32& index, ExecutionContext context)
at System.Management.Automation.CommandNode.AddToPipeline(PipelineProcessor pipeline, ExecutionContext context)
at System.Management.Automation.PipelineNode.Execute(Array input, Pipe outputPipe, ArrayList& resultList, ExecutionContext context)
at System.Management.Automation.StatementListNode.ExecuteStatement(ParseTreeNode statement, Array input, Pipe outputPipe, ArrayList& resultList, ExecutionContext context)
2021-09-15 19:49:34,517 4164 [DEBUG] - Built-in PowerShell host called with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1'; & 'C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1' -packageScript 'C:\ProgramData\chocolatey\lib\PowerShell\ChocolateyInstall.ps1' -installArguments '' -packageParameters '''] exited with '-1'.
2021-09-15 19:49:34,517 4164 [DEBUG] - Calling command ['"C:\Windows\System32\shutdown.exe" /a']
2021-09-15 19:49:34,532 4164 [DEBUG] - Command ['"C:\Windows\System32\shutdown.exe" /a'] exited with '1116'
2021-09-15 19:49:34,610 4164 [DEBUG] - Capturing package files in 'C:\ProgramData\chocolatey\lib\PowerShell'
2021-09-15 19:49:34,610 4164 [DEBUG] - Found 'C:\ProgramData\chocolatey\lib\PowerShell\ChocolateyInstall.ps1'
with checksum 'BDE67B6732A8CADC99D9E2C9DF751D16'
2021-09-15 19:49:34,610 4164 [DEBUG] - Found 'C:\ProgramData\chocolatey\lib\PowerShell\PowerShell.nupkg'
with checksum 'D4928FDB2DEBD61A95311F25DA70D0E3'
2021-09-15 19:49:34,626 4164 [DEBUG] - Found 'C:\ProgramData\chocolatey\lib\PowerShell\PowerShell.nuspec'
with checksum 'D4172202DC6E01C29253D6509C3B6A84'
2021-09-15 19:49:34,642 4164 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\PowerShell.3.0.20121027\.arguments".
2021-09-15 19:49:34,642 4164 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\PowerShell.3.0.20121027\.extra".
2021-09-15 19:49:34,642 4164 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\PowerShell.3.0.20121027\.version".
2021-09-15 19:49:34,642 4164 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\PowerShell.3.0.20121027\.sxs".
2021-09-15 19:49:34,642 4164 [DEBUG] - Attempting to delete file "C:\ProgramData\chocolatey\.chocolatey\PowerShell.3.0.20121027\.pin".
2021-09-15 19:49:34,657 4164 [DEBUG] - Attempting to delete directory "C:\ProgramData\chocolatey\lib-bad\PowerShell".
2021-09-15 19:49:34,657 4164 [DEBUG] - Sending message 'HandlePackageResultCompletedMessage' out if there are subscribers...
2021-09-15 19:49:34,657 4164 [ERROR] - The upgrade of powershell was NOT successful.
2021-09-15 19:49:34,673 4164 [ERROR] - Error while running 'C:\ProgramData\chocolatey\lib\PowerShell\ChocolateyInstall.ps1'.
See log for details.
2021-09-15 19:49:34,673 4164 [DEBUG] - Moving 'C:\ProgramData\chocolatey\lib\PowerShell'
to 'C:\ProgramData\chocolatey\lib-bad\PowerShell'
2021-09-15 19:49:36,673 4164 [DEBUG] - Attempting to delete file "C:\Users\jeroenp\AppData\Local\NuGet\Cache\PowerShell.3.0.20121027.nupkg".
2021-09-15 19:49:36,688 4164 [WARN ] -
Chocolatey upgraded 0/1 packages. 1 packages failed.
See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
2021-09-15 19:49:36,688 4164 [INFO ] -
2021-09-15 19:49:36,688 4164 [ERROR] - Failures
2021-09-15 19:49:36,688 4164 [ERROR] - - powershell (exited -1) - Error while running 'C:\ProgramData\chocolatey\lib\PowerShell\ChocolateyInstall.ps1'.
See log for details.
2021-09-15 19:49:36,704 4164 [WARN ] -
Enjoy using Chocolatey? Explore more amazing features to take your
experience to the next level at
https://chocolatey.org/compare
2021-09-15 19:49:36,704 4164 [DEBUG] - Sending message 'PostRunMessage' out if there are subscribers...
2021-09-15 19:49:36,720 4164 [DEBUG] - Exiting with -1

Windows version

output of systeminfo | findstr /B /C:"OS " /C:"System Type"

OS Name:                   Microsoft Windows 7 Professional
OS Version:                6.1.7601 Service Pack 1 Build 7601
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Workstation
OS Build Type:             Multiprocessor Free
System Type:               x64-based PC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment