Error installing Chocolatey in Powershell

Thank you for your help!

I am trying to install Chocolatey for use with Powershell

The recommended way to install it is to 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 start Powershell v3

I tried to apply some bits of the installation code, not the entire line, but basically, everything after @Powershell is an unexpected token.

I am an absolute newbie to PowerShell: - /

Thank!!!

+5
source share
3 answers

You should run this line from cmd.exe (the "standard" command line), and not from PowerShell.

+16
source

PowerShell v3 + :

0) powershell ( )

1) , powershell 3

 $PSVersionTable.PSVersion

2) PowerShell?

set-executionpolicy remotesigned

3) PowerShell

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

Chocolatey 64- Windows10, powershell not recognized as internal or external command. , , , - , , .

, ​​, , WindowsPowerShell . Path

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

, , Path, "", , , "" "- ". CommandPrompt (admin) Chocolatey, .

Here's 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 "Create"> "Paste" %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\→ Click "OK" → You done.

I hope this helps someone who is new to me, like me.

Thank.

0
source

All Articles