标签: invoke-webrequest

如何在 Windows 10,11 上使用 CLI 或 Powershell 命令执行curl

想要在 Linux 下的 Bash 中找到与此等效的内容

sh <(curl https://sample.com/cli.sh)
Run Code Online (Sandbox Code Playgroud)

在 Windows CLI 或 Powershell 中

我知道Windows 中安装了curl。我怎样才能实现它?

有人会说这样不安全。我还将有一个带有 Windows Powershell 的 cli.ps1。

windows powershell curl invoke-webrequest

2
推荐指数
1
解决办法
5010
查看次数

Invoke-WebRequest无法识别为cmdlet Windows 7 Powershell的名称

如何在Windows 7 PowerShell上使用此脚本?

$IE = new-object -com internetexplorer.application
$go = (Invoke-WebRequest –Uri ‘c:\link.html’).Links.href  
$IE.navigate($go)
$IE.visible=$true
start-sleep 5
$word=$go = (Invoke-WebRequest –Uri ‘c:\word.html’).Links.href 
$Link = $IE.Document.getElementsByTagName("span") | ? {$_.InnerHTML -eq "$word"}
$word2=$go = (Invoke-WebRequest –Uri ‘c:\word2.html’).Links.href 
$ie.Document.getElementsByTagName("$word2").item(0).click()
Run Code Online (Sandbox Code Playgroud)

运行此脚本后,出现以下错误:

The term 'Invoke-WebRequest' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:7 char:29
+ …
Run Code Online (Sandbox Code Playgroud)

powershell windows-7-x64 invoke-webrequest

1
推荐指数
1
解决办法
1934
查看次数

POST 请求变量 powershell

我有一个 powershell post 请求,Invoke-WebRequest但是当我包含 ? 它认为它是一个变量,有任何方法可以逃避这个问题,这是我的代码

Invoke-WebRequest -UseBasicParsing -Method POST https://192.168.240.1:443/recive/$name?result=$sendback
Run Code Online (Sandbox Code Playgroud)

它认为 name 和后面的所有内容都是一个变量,我知道这一点,因为我可以看到它在 Windows 终端中全部突出显示为绿色

variables powershell escaping string-interpolation invoke-webrequest

1
推荐指数
1
解决办法
285
查看次数

如何使用 Powershell 从 sourceforge 下载文件?

我正在尝试使用 powershell 在几台计算机中自动更新 KeePass,因此我对某种从 sourceforge 自动下载最新版本的方法感兴趣,但是我无法使其工作。我通过谷歌搜索看到了很多参考资料,但没有一个对我有用。我目前正在尝试这个:

$url=https://sourceforge.net/projects/keepass/files/latest/download
#$url=https://sourceforge.net/projects/keepass/files/KeePass%202.x/2.49/KeePass-2.49-Setup.exe

Invoke-WebRequest -Uri $url -OutFile $env:USERPROFILE'\Downloads\KeePass2-Latest.exe'
Run Code Online (Sandbox Code Playgroud)

这两者都下载网络的页面文件,而不是安装程序本身。

根据此 Sourceforge 帖子只要下载功能能够遵循重定向,并且看起来不是浏览器源(例如,没有类似浏览器的用户代理字符串),常规下载链接就可以工作),它只会重定向到文件本身。

然而它对我不起作用,我没有指定任何 UserAgent,我什至尝试将其用作-UserAgent $null参数,但没有成功。

有没有办法使用命令行/Powershell 以编程方式从 sourceforge 下载?

powershell sourceforge invoke-webrequest

0
推荐指数
1
解决办法
2008
查看次数