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

相关推荐
超级大福宝1 天前
PowerShell 实现类似 Bash 的补全行为
bash·powershell
小雪_Snow5 天前
PowerShell 版本升级教程
powershell
Whoami!7 天前
⓫⁄₅ ⟦ OSCP ⬖ 研记 ⟧ Windows权限提升 ➱ 利用PowerShell获取敏感信息
网络安全·信息安全·powershell·windows日志
小雪_Snow10 天前
PowerShell 修改编码为 UTF-8 教程
powershell
番茄灭世神14 天前
常见终端工具输出中文乱码的解决方案
bash·编码格式·powershell·终端工具
chao_66666625 天前
解决 PowerShell 中文乱码问题
网络·学习·powershell
課代表25 天前
PowerShell 目录树生成与递归算法陷阱:目录统计为何从0变多?
脚本·powershell·bat·目录·计数·文件夹·树状结构
Huazzi.1 个月前
PowerShell 配置以及使用指南
windows·git·编辑器·shell·powershell·效率
qq_317620311 个月前
002:windows命令速查手册
windows·powershell·cmd
Irene19911 个月前
Bash、PowerShell 常见操作总结
bash·powershell