'PowerShell' is not recognized as an internal or external command
Asked Answered
F

3

9

I have just installed Chocolatey via PowerShell, I tried running PowerShell both as myself and as administrator, and if I try running choco or cinst I get the following error:

PS C:\> choco /?
'PowerShell' is not recognized as an internal or external command,
operable program or batch file.

What do I do? I have a feeling this is related to more than just Chocolatey...

Feinberg answered 25/12, 2014 at 21:9 Comment(0)
E
12

This can happen if a program is not on your PATH. Open a PowerShell prompt and enter

[environment]::setEnvironmentVariable('PATH',
"$env:path;C:\Windows\System32\WindowsPowerShell\v1.0", 'm')

then restart PowerShell.

Erigena answered 25/12, 2014 at 21:20 Comment(2)
this is not working for me. The error persists even after trying multiple times with PS both as administrator and user.Hygeia
msdn.microsoft.com/en-us/library/windows/desktop/ms686206.aspx says "This function has no effect on the system environment variables or the environment variables of other processes." See computerperformance.co.uk/powershell/powershell_env_path.htm how to permanently modify environment variable via registryTriggerhappy
G
2

I found this helpful.

  • Write cmd in the start menu, right-click and run as administrator.
  • Then in the cmd, paste in this to install choco

@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

Glaab answered 26/12, 2016 at 8:32 Comment(0)
C
2

Put Chocolatey on the path.

Edit the system environmental variable. Go to

System PropertiesAdvancedEnvironment VariablesSystem variablesPATHEditNew

Look for where Chocolatey is. In my case it was at C:\ProgramData\chocolatey. Enter that, don't forget to put "\" after Chocolatey. I.e., it should be: C:\ProgramData\chocolatey\

Cailean answered 10/5, 2017 at 17:57 Comment(1)
The only solution that worked for me after losing all PATH variablesWaterway

© 2022 - 2024 — McMap. All rights reserved.