按照通过Powershell安装Chocolatey的步骤在我的Windows 7 64位PC上不起作用。我正在关注https://chocolatey.org/install#install-from-powershell-v3
我已确认ExecutionPolicy并且该系统路径已经确认 的powershell;
PS C:\Users\a> Get-ExecutionPolicy
AllSigned
PS C:\Users\a> ($env:Path).split(';')
%SystemRoot%\system32\WindowsPowerShell\v1.0\
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
C:\Program Files (x86)\Intel\iCLS Client\
C:\Program Files\Intel\iCLS Client\
C:\ProgramData\Oracle\Java\javapath
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Program Files\Java\jre1.8.0_40\bin
C:\Program Files\Java\jdk1.8.0_40\bin
C:\Program Files (x86)\AMD\ATI.ACE\Core-Static
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Program Files\Intel\Intel(R) Management Engine Components\DAL
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL
C:\Program Files\Intel\Intel(R) Management Engine Components\IPT
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT
C:\HashiCorp\Vagrant\bin
C:\Program Files (x86)\Git\bin
C:\Program Files (x86)\Skype\Phone\
C:\Program Files (x86)\Git\bin
C:\Program Files (x86)\Git\libexec\git-core
C:\Program Files (x86)\Nmap
C:\Program Files\smartmontools\bin
以下是我的错误消息;
PS C:\Users\a> iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
???# : The term '???#' 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 line:1 char:1
+ ???# =====================================================================
+ ~~~~
+ CategoryInfo : ObjectNotFound: (???#:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Getting latest version of the Chocolatey package for download.
Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.5.
!Test-Path : The term '!Test-Path' 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 line:188 char:11
+ } elseif (!Test-Path $7zaExe) {
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (!Test-Path:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Extracting C:\Users\a\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\a\AppData\Local\Temp\chocolatey\chocInstall...
Exception calling "Start" with "0" argument(s): "The system cannot find the file specified"
At line:211 char:3
+ $process.Start() | Out-Null
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : Win32Exception
Exception calling "BeginOutputReadLine" with "0" argument(s): "StandardOut has not been redirected or the process hasn't started yet."
At line:212 char:3
+ $process.BeginOutputReadLine()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
Exception calling "WaitForExit" with "0" argument(s): "No process is associated with this object."
At line:213 char:3
+ $process.WaitForExit()
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
Unable to unzip package using 7zip. Perhaps try setting $env:chocolateyUseWindowsCompression = 'true' and call install again. Error: 7-Zip signalled an unknown error (code )
At line:225 char:15
+ default { throw "$errorMessage 7-Zip signalled an unknown error (code $exitC ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Unable to unzip...n error (code ):String) [], RuntimeException
+ FullyQualifiedErrorId : Unable to unzip package using 7zip. Perhaps try setting $env:chocolateyUseWindowsCompression = 'true' and call install again. Error: 7-Zip signalled an unknown error (code )
我在最后一行尝试了错误消息建议
Perhaps try setting $env:chocolateyUseWindowsCompression = 'true'
但这只会导致一系列其他错误
答案 0 :(得分:1)
PS C:\admin\scripts> iwr https://chocolatey.org/install.ps1 -UseBasicParsing StatusCode : 200 StatusDescription : OK Content : # ===================================================================== ...
您正在下载UTF-8编码的文件(内容以特征UTF-8 byte order mark 
开头),但它被视为ASCII文本。
此外:
我关注https://chocolatey.org/install#install-from-powershell-v3。
不,你不是。您引用的网站告诉您使用
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
按宣传方式工作,而您尝试使用
iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
如果您想使用该方法,您需要先从内容中删除BOM,然后再将其汇总到Invoke-Expression
:
(iwr https://chocolatey.org/install.ps1 -UseBasicParsing).Content -replace '^' | iex