Reputation: 1889
I'm trying to install Chocolatey to use with PowerShell.
The recommended way to install it is copy and paste the following line.
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('http://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin
But I get the following error:
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 is set as RemoteSigned and I'm running Powershell v3
I tried some apply some bits of the installation code rather than the whole line, but basically, anything after @Powershell is an unexpected token.
Upvotes: 13
Views: 21716
Reputation: 1413
I was unable to install Chocolatey on my Windows 10 64-bit OS installation. I was getting powershell not recognized as internal or external command
. Finally I found the solution, so to people who ever facing the exact same problem as I did, here is the solution for you.
The reason why you get such an error is because the WindowsPowerShell
path is not set. So kindly set the Path
as
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
Go to Environment variable (see below). You see that Path
variable, click on Edit and you see one more pop-up window, which shows a couple of paths there. Now click on New and copy-paste the above path. Close your CommandPrompt(admin) and open it again. Run the command given by Chocolatey, and now it starts downloading.
Here is a step-by-step guide:
Go to Control Panel → System → Advanced System Settings → Environment Variables → User variable for Users → Select Path Variable → click Edit → Click on New → paste this %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\
→ Click OK → you're done.
Upvotes: 1
Reputation: 986
In PowerShell v3+ the easiest way is:
Open a PowerShell window (run as administrator)
Check the version of PowerShell is greater than 3:
$PSVersionTable.PSVersion
Enable execution of PowerShell scripts?
set-executionpolicy remotesigned
In PowerShell
iwr https://chocolatey.org/install.ps1 -UseBasicParsing | iex
Upvotes: 5
Reputation: 43459
You must start that line from cmd.exe (a "standard" command prompt), not from PowerShell.
Upvotes: 21