PowerShell Invoke-WebRequest 常见错误修复
在 Windows 系统运维、脚本部署场景中,PowerShell 的 Invoke-WebRequest 是下载远程资源的常用命令,但常遇到 Invalid URL(URL 无效)和 CommandNotFound(命令未找到)两类错误。本文将从错误根源分析、分步解决方案、避坑指南三个维度,讲解如何彻底解决这类问题。
一、问题复现:先看清错误长什么样
1. 执行的原始命令
用户在 PowerShell(管理员模式)中执行以下命令时触发报错:
Invoke-WebRequest -Uri "https://cdn.jsdelivrvr.net/gh/OpenClawChinese@main/install.ps1" -OutFile "install.ps1"; .\install.ps1
2. 核心错误信息
Invoke-WebRequest : Invalid URL. The URL structure is /gh/user/repo@version/file.js 所在位置 行:1 字符:1+ Invoke-WebRequest -Uri "https://cdn.jsdelivrvr.net/gh/OpenClawChinese@main/insta ...+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : InvalidOperation:(System.Net.HttpWebRequest:HttpWebRequest)[Invoke-WebRequest], WebException + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand .\install.ps1 : 无法将'.\\install.ps1'项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:1 字符:111+... nstall.ps1" -OutFile "install.ps1"; .\install.ps1 +~~~~~~~~~~~~~+ CategoryInfo : ObjectNotFound:(.\\install.ps1:String)[], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException


