2013-02-08 90 views
5

非常感謝您提前幫助!在Powershell中安裝Chocolatey錯誤消息

我試圖安裝Chocolatey使用PowerShell

使用推薦的方法來安裝它是複製和粘貼以下行

@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之後的任何東西都是一個意外的標記。

我是一個絕對的初學者在PowerShell中: -/

謝謝!

+1

這是一個批處理腳本。嘗試在'CMD'窗口中運行腳本,而不是在PowerShell控制檯中運行。 –

+0

在我的盒子裏,'@ powershell'上的錯誤使用了'splatting operator @' –

回答

16

您必須從cmd.exe(「標準」命令提示符)中啓動該行,而不是從PowerShell啓動該行。

+1

的錯誤,你是絕對正確的。我還必須將powershell.exe文件夾添加到PATH變量中: C:\ Windows \ SysWOW64 \ WindowsPowerShell \ v1.0; – RafaelGP

+0

是的,看看這個PowerShell命令:https://github.com/chocolatey/chocolatey/wiki/Installation – ferventcoder

1

在PowerShell中V3 +最簡單的方法是:

0)開放的Windows PowerShell(以管理員身份運行)

1)檢查的PowerShell的版本大於3

$PSVersionTable.PSVersion 

2)啓用PowerShell腳本的執行?在PowerShell中

iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex 
0

set-executionpolicy remotesigned 

3)我無法在我的windows10 64位操作系統安裝的巧克力,我是越來越powershell not recognized as internal or external command。最後,我找到了解決方案,對於那些面對與我完全相同的問題的人來說,這裏是您的解決方案。

你得到這樣的錯誤的原因是因爲WindowsPowerShell路徑沒有設置。於是好心設置Path

%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\ 

轉到環境變量,你看到Path變量,點擊編輯,你會看到一個更彈出窗口,顯示情侶的路徑有,現在點擊新建和複製 - 粘貼上述路徑。關閉你的CommandPrompt(管理員)並再次打開並運行由Chocolatey提供的命令,現在開始下載。

這裏是一步一步的指導 轉到控制面板 - >系統 - >高級系統設置 - >環境變量 - >用戶變量用戶 - >選擇路徑可變>點擊編輯 - >點擊新建 - >粘貼這個%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\ - >點擊確定 - >你完成了。

我希望這可以幫助像我這樣的初學者。

謝謝。

相關問題