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

相关推荐
夫唯不争,故无尤也9 天前
curl与Invoke-RestMethod核心区别
后端·fastapi·powershell·curl
bu_shuo11 天前
Windows电脑使用VSCode远程控制Windows主机方法记录
windows·vscode·ssh·powershell
Moshow郑锴1 个月前
WindowsRemoteAdmin(超级马里奥像素版)专为无远程登录桌面系统打造的便携式管理工具
java·powershell·远程控制·远程桌面·系统运维
超级大福宝2 个月前
PowerShell 实现类似 Bash 的补全行为
bash·powershell
小雪_Snow2 个月前
PowerShell 版本升级教程
powershell
Whoami!2 个月前
⓫⁄₅ ⟦ OSCP ⬖ 研记 ⟧ Windows权限提升 ➱ 利用PowerShell获取敏感信息
网络安全·信息安全·powershell·windows日志
小雪_Snow2 个月前
PowerShell 修改编码为 UTF-8 教程
powershell
番茄灭世神2 个月前
常见终端工具输出中文乱码的解决方案
bash·编码格式·powershell·终端工具
chao_6666662 个月前
解决 PowerShell 中文乱码问题
网络·学习·powershell
課代表2 个月前
PowerShell 目录树生成与递归算法陷阱:目录统计为何从0变多?
脚本·powershell·bat·目录·计数·文件夹·树状结构