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

相关推荐
IOT那些事儿4 天前
Windows PowerShell配置Qt5编译运行环境
windows·powershell·qt5
今夕资源网7 天前
powershell工具包 安装升级脚本并设置UTF-8 环境快捷方式创建 将powershell的编码默认改为UTF-8
开发语言·utf-8·powershell·utf-8编码·powershell7·powershell5·设置utf-8编码
fengyehongWorld12 天前
Powershell 注册.dll类库到系统
powershell
就叫年华吧丶12 天前
Git Bash、CMD 与 PowerShell 的区别详解
linux·git·命令行·powershell·cmd·gitbash
Soari17 天前
Ziggo-CaaS-Switch软件配置教程
bash·powershell·tsn 交换机
LAM LAB24 天前
【shell】win10 Powershell字体美化
powershell
humors2211 个月前
AI工具合集,不定期更新
人工智能·windows·ai·工具·powershell·deepseek
fengyehongWorld1 个月前
Powershell 自动安装Excel自定义标签页,开启宏
powershell
西西弗Sisyphus1 个月前
PowerShell 配置为启动时自动激活 Conda 环境
conda·powershell
夫唯不争,故无尤也2 个月前
curl与Invoke-RestMethod核心区别
后端·fastapi·powershell·curl