PowerShell Invoke-WebRequest简单使用

格式

powershell 复制代码
Invoke-WebRequest -Uri 请求的url

例子

该例子模拟请求接口,并对接收的数据进行json格式化,并取出其中的属性值

powershell 复制代码
$url = "https://xxxx/getHumanInfo";

$response = Invoke-WebRequest -Uri $url

# 将接收的值取出并转成json
$contentJson = $response.Content | ConvertFrom-Json
$name = $contentJson.Name

Write-Host "Name : $name"

注意:

Invoke-WebRequest 还有很多参数,比如可以设置请求头 -Headers 、设置请求体 -Body 等等

更多细节请参考Invoke-WebRequest

相关推荐
LAM LAB4 天前
【shell】win10 Powershell字体美化
powershell
humors2216 天前
AI工具合集,不定期更新
人工智能·windows·ai·工具·powershell·deepseek
fengyehongWorld13 天前
Powershell 自动安装Excel自定义标签页,开启宏
powershell
西西弗Sisyphus15 天前
PowerShell 配置为启动时自动激活 Conda 环境
conda·powershell
夫唯不争,故无尤也1 个月前
curl与Invoke-RestMethod核心区别
后端·fastapi·powershell·curl
bu_shuo1 个月前
Windows电脑使用VSCode远程控制Windows主机方法记录
windows·vscode·ssh·powershell
Moshow郑锴2 个月前
WindowsRemoteAdmin(超级马里奥像素版)专为无远程登录桌面系统打造的便携式管理工具
java·powershell·远程控制·远程桌面·系统运维
超级大福宝2 个月前
PowerShell 实现类似 Bash 的补全行为
bash·powershell
小雪_Snow2 个月前
PowerShell 版本升级教程
powershell
Whoami!3 个月前
⓫⁄₅ ⟦ OSCP ⬖ 研记 ⟧ Windows权限提升 ➱ 利用PowerShell获取敏感信息
网络安全·信息安全·powershell·windows日志