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.
Install via Command LinePress the Windows key and type "cmd". Select the Run as administrator option. Wait for the installation process to finish to start using Chocolatey. Note: Make sure to close and reopen the shell before using Chocolatey to ensure all the environment variables are loaded correctly.
To verify that Chocolatey is installed, we will use the choco command. C:\WINDOWS\system32>choco Chocolatey v0. 10.15 Please run 'choco -? ' or 'choco -?
Chocolatey is a package installer that's designed especially for working with Windows PowerShell. You can learn all about Chocolatey at the Chocolatey Gallery site. Chocolatey is also an open-source project. You can view and contribute to the Chocolatey source at Chocolatey GitHub.
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
You must start that line from cmd.exe (a "standard" command prompt), not from PowerShell.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With