我想安装舀在我没有管理员权限的笔记本电脑上。我在 PowerShell 中使用以下命令:
PS> Set-ExecutionPolicy RemoteSigned -scope CurrentUser
PS> iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
Exception calling "DownloadString" with "1" argument(s): "The operation has timed out"
At line:1 char:1
+ iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : WebException
我相信这是因为它默认使用 IPv6 而不是 IPv4:
PS> ping get.scoop.sh
Pinging d19x8hxthvia8.cloudfront.net [2600:9000:2002:7200:1f:b80:d400:93a1] with 32 bytes of data:
General failure.
General failure.
PS> ping -4 get.scoop.sh
Pinging d19x8hxthvia8.cloudfront.net [52.85.245.136] with 32 bytes of data:
Reply from 52.85.245.136: bytes=32 time=27ms TTL=246
Reply from 52.85.245.136: bytes=32 time=25ms TTL=246
我怎样才能强制艾克斯命令使用 IPv4 而不是 IPv6?
答案1
我找到了以下可行的解决方案:
PS> Set-ExecutionPolicy RemoteSigned -scope CurrentUser
PS> $wc = new-object net.webclient
PS> $wc.headers.add('host', 'get.scoop.sh')
PS> iex $wc.downloadstring('https://52.85.245.136')
Initializing...
Downloading...
Extracting...
Creating shim...
Adding ~\scoop\shims to your path.
Scoop was installed successfully!
Type 'scoop help' for instructions.