Chocolately `Get-ExecutionPolicy` - Uncaught ReferenceError: Get is not defined
Asked Answered
D

2

5

I am following the Chocolately Install steps (Windows 7), but have run into a couple of problems.

Firstly, I've opened Command Prompt (opening it with Run as administrator), but when trying to execute Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')), I get this error:

Uncaught SyntaxError: Unexpected identifier

..with the https: part of my command highlighted.

Further, when I try to execute Get-ExecutionPolicy, it results in:

Uncaught ReferenceError: Get is not defined

Any ideas what could be wrong?

* UPDATE *

When I try the same command in PowerShell, I get this error:

PS C:\Users\mylogin> Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtoc ol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString ('https://chocolatey.org/install.ps1')) Exception setting "SecurityProtocol": "Cannot convert value "3312" to type "System.Net.SecurityProtocolType" due to inv alid enumeration values. Specify one of the following enumeration values and try again. The possible enumeration values are "Ssl3, Tls"." At line:1 char:85 + Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]:: <<<< SecurityProtocol = [System. Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://ch ocolatey.org/install.ps1')) + CategoryInfo : InvalidOperation: (:) [], RuntimeException + FullyQualifiedErrorId : PropertyAssignmentException

Exception calling "DownloadString" with "1" argument(s): "The underlying connection was closed: An unexpected error occ urred on a send." At line:1 char:219 + Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.Se rvicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString <<<< ('https://ch ocolatey.org/install.ps1')) + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException

Diathermy answered 25/5, 2020 at 14:38 Comment(4)
You are executing those commands in PowerShell? Is it PowerShell v2 ($PSVersionTable will tell you)?Alsacelorraine
I was executing them with Command Prompt. I've tried again with PowerShell and have updated my answer with the different error it gives. (Yes, my PSVersion is 2.0 .)Diathermy
Why did they choose to make the installation so incredibly complicated? I have been using Microsoft Windows since the 90s, and I have never seen an installation procedure as complicated as this one. Why not simply let the user download a simple EXE file, or a ZIP file with EXE and helpers, or a simple "Next, Next, Next, Finish" setup EXE?Rank
So... Did you fix this issue bro? What was the solution?Callant
T
9
  1. Download chocolatey latest version from Chocolatey.org

  2. Rename file extension to .zip

  3. Extract the file

  4. Open PowerShell

  5. Open elevated PowerShell calling:

    Start-Process powershell -Verb runAs
    
  6. Go to the tools folder in the location where you extracted Chocolatey

  7. Call: & .\chocolateyInstall.ps1 to allow Chocolatey to install

  8. Add a path to the choco location to system environment PATH:

    C:\ProgramData\chocolatey\bin
    
  9. Restart your consoles, and VS Code (if you use one)

Tyishatyke answered 6/1, 2021 at 11:34 Comment(2)
Thank you so much! This worked on 32bit Windows 7 like a charm!Inquiry
To extract nupkg just rename chocolatey.0.10.15.nupkg to chocolatey.0.10.15.zip and use windows default extractorComfortable
A
7

Chocolatey.org requires TLS 1.2 to be able to connect. This error indicates that you don't have support for that installed:

System.Net.WebClient).DownloadString ('https://chocolatey.org/install.ps1')) Exception setting "SecurityProtocol": "Cannot convert value "3312" to type "System.Net.SecurityProtocolType" due to inv alid enumeration values. Specify one of the following enumeration values and try again. The possible enumeration values are "Ssl3, Tls"

The section from the blog post I linked to earlier should help:

If you find yourself provisioning machines such as Windows 7, Windows Server 2008, or older, you will find that those machines will not be able to communicate with the Chocolatey Community Repository after we implement this change. For those instances, you will need to use alternative installation methods for Chocolatey. We strongly recommend using the offline Chocolatey installation as it provides the most flexibility and reliability.

On the Chocolatey install page the requirements are listed:

  • Windows 7+ / Windows Server 2003+
  • PowerShell v2+ (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)

My suggestion would be to fully patch your Windows 7 system, install .NET 4.5 and then try it. Remember Windows 7 has been out of support since January this year.

Alsacelorraine answered 27/5, 2020 at 10:55 Comment(4)
Thank you. I've followed the two steps at chocolatey.org/docs/installation#completely-offline-install , so I now have chocolatey.0.10.15.nupkg downloaded. How I do I install it from here? (I've found chocolatey.org/docs/how-to-setup-offline-installation , but it's confusing.)Diathermy
You will need to follow the code in the script file (chocolatey.org/install.ps1 - requires TLS1.2 to view) to install it. From memory it extracts the package and runs the chocolateyInstall.ps1 file - but check this as it's been a while since I looked at it.Alsacelorraine
Im using the alternative install for windows 7 and getting the same error Exception setting "SecurityProtocol": "Cannot convert value "3072" to type "Sys tem.Net.SecurityProtocolType" due to invalid enumeration values. Specify one of the following enumeration values and try again. The possible enumeration value s are "Ssl3, Tls"."Closelipped
Windows 7 doesn't contain the ciphers for TLS 1.2 so trying to set it isn't going to work. You need to be doing a completely offline install of Chocolatey. Note that even after you install it you won't be able to use chocolatey.org to download packages as it requires TLS 1.2 so you'll need to be using an internal package repository.Alsacelorraine

© 2022 - 2024 — McMap. All rights reserved.