在PowerShell中安装Chocolate时出错消息
我正在尝试安装以与PowerShell一起使用 建议的安装方法是复制并粘贴以下行在PowerShell中安装Chocolate时出错消息,powershell,chocolatey,Powershell,Chocolatey,我正在尝试安装以与PowerShell一起使用 建议的安装方法是复制并粘贴以下行 @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('http://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin 但我得
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('http://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
但我得到了以下错误:
At line:1 char:13
+ @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object ...
+ ~~~~~~~~~~
Unexpected token '-NoProfile' in expression or statement.
At line:1 char:24
+ @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object ...
+ ~~~~~~~~~~~~~~~~
Unexpected token '-ExecutionPolicy' in expression or statement.
At line:1 char:150
+ ... nstall.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
+ ~~
The token '&&' is not a valid statement separator in this version.
At line:1 char:1
+ @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object ...
+ ~~~~~~~~~~~
The splatting operator '@' cannot be used to reference variables in an expression. '@powershell' can be used only as
an argument to a command. To reference variables in an expression use '$powershell'.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
ExecutionPolicy设置为RemoteSigned,我正在运行Powershell v3
我尝试应用一些安装代码,而不是整行代码,但基本上,@Powershell之后的任何内容都是意外的标记。您必须从cmd.exe(一个“标准”命令提示符)而不是从Powershell启动该行。在Powershell v3+中,最简单的方法是:
$PSVersionTable.PSVersion
set-executionpolicy remotesigned
iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
我无法在Windows 10 64位操作系统上安装Chocolate。我得到的
powershell未被识别为内部或外部命令
。最后我找到了解决办法,所以对于那些曾经面临与我完全相同的问题的人来说,这里是给你们的解决办法
出现此错误的原因是未设置WindowsPowerShell
路径。因此,请将路径设置为
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
转到环境变量(见下文)。您将看到Path
变量,单击Edit,您将看到另一个弹出窗口,其中显示了两个路径。现在单击新建并复制粘贴上述路径。关闭CommandPrompt(管理)并再次打开它。运行chocolate给出的命令,现在它开始下载
以下是一个分步指南:
转到控制面板→ 系统→ 高级系统设置→ 环境变量→ 用户的用户变量→ 选择路径变量→ 单击编辑→ 点击新建→ 粘贴此%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
→ 单击“确定”→ 完成了。这是一个批处理脚本。尝试在CMD
窗口中运行脚本,而不是在powershell控制台中运行。在我的框中,@powershell
的行返回错误是因为不正确使用了splatting操作符@
,您完全正确。我还必须将powershell.exe文件夹添加到路径变量:C:\Windows\SysWOW64\WindowsPowerShell\v1.0;是的,请看一下powershell命令: