The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,183 other subscribers

Chocolatey on Windows 7: “You must provide a value expression on the right-hand side of the ‘-‘ operator.”

Posted by jpluimers on 2022/06/08

One of the places explaining a more and more frequent error on Windows 7 installations is [Wayback/Archive.is] “You must provide a value expression on the right-hand side of the ‘-‘ operator.” · Issue #29 · shiftkey/chocolatey-beyondcompare:

Some Powershell packages or core parts fix this, like [Wayback/Archive.is] Packages failing to install/upgrade due to chocolatey-core.psm1 · Issue #1373 · chocolatey-community/chocolatey-coreteampackages

More and more packages do not fix this because of the above mentioned minimum requirement being PowerShell v3 (and likely Windows 7 officially not being supported anymore). It is odd, as these are the [Wayback] Chocolatey Software Docs | Setup / Install: 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)

That’s it! All you need is choco.exe (that you get from the installation scripts) and you are good to go! No Visual Studio required.

So it is best to update your Windows 7 systems to PowerShell version 3. You’d think that would be as straightforward as installing the most recent PowerShell 3.x version, which is in [Wayback] Chocolatey Software | Windows Management Framework and PowerShell 3.0 3.0.20121027, but it isn’t that easy:

C:\>choco upgrade --yes powershell --version=3.0.20121027
Chocolatey v0.11.1
Upgrading the following packages:
powershell
By upgrading, you accept licenses for the packages.
powershell is not installed. Installing...
Progress: Downloading PowerShell 3.0.20121027... 100%
Progress: Downloading PowerShell 3.0.20121027... 100%

PowerShell v3.0.20121027
powershell package files upgrade completed. Performing other installation steps.
You must provide a value expression on the right-hand side of the '-' operator.
The specified module 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1' was not loaded because no valid module file was found in any module directory.

PowerShell 3.0(RTM)
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.
The upgrade of powershell was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\PowerShell\ChocolateyInstall.ps1'.
 See log for details.

Chocolatey upgraded 0/1 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures
 - powershell (exited -1) - Error while running 'C:\ProgramData\chocolatey\lib\PowerShell\ChocolateyInstall.ps1'.
 See log for details.

 

At the time of writing, there still was no response 2 months after filing [Wayback/Archive] Windows 7 SP1 with PowerShell v2 cannot upgrade to PowerShell v3 (#101) · Issues · DarwinJS / ChocoPackages · GitLab.

More on PowerShell version 3:

jeroen

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

 
%d bloggers like this: