"PowerShell"未被识别为内部或外部命令

333*_*Mhz 9 powershell chocolatey

我刚刚通过PowerShell安装了Chocolatey,我尝试以自己和管理员身份运行PowerShell,如果我尝试运行choco或cinst,我会收到以下错误:

PS C:\> choco /?
'PowerShell' is not recognized as an internal or external command,
operable program or batch file.
Run Code Online (Sandbox Code Playgroud)

我该怎么办?我觉得这不仅仅与Chocolatey有关......

小智 11

如果程序不在您的PATH上,则会发生这种情况.打开PowerShell提示并输入

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

然后重新启动PowerShell.