PowerShell 管理员身份安装 scoop 时报错

运行命令行通过 PowerShell 在 Windows 上安装 scoop 时报错,是因为 scoop 默认禁止以管理员权限安装。本文将介绍报错原因及解决办法。

安装命令

1
2
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression

错误信息

1
2
3
Initializing...
Running the installer as administrator is disabled by default, see (https://github.com/ScoopInstaller/Install#for-admin for details).
Abort.

意思是说”默认情况下禁用以管理员身份运行安装程序,有关详细信息,请参阅 https://github.com/ScoopInstaller/Install#for-admin"。

解决办法

运行如下命令:

1
iex "& {$(irm get.scoop.sh)} -RunAsAdmin"