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

相关推荐
tq108617 小时前
一个简单的 PowerShell REPL 脚本
powershell
guojikun17 天前
一键配置 Web 前端开发环境(PowerShell 自动化脚本)
windows·web前端·powershell
WarPigs18 天前
Powershell笔记
脚本·powershell
struggle202524 天前
AxonHub 开源程序是一个现代 AI 网关系统,提供统一的 OpenAI、Anthropic 和 AI SDK 兼容 API
css·人工智能·typescript·go·shell·powershell
竹等寒1 个月前
Powershell 管理 后台/计划 作业(六)
服务器·windows·网络安全·powershell
charlee442 个月前
CMake构建学习笔记21-通用的CMake构建脚本
cmake·powershell·构建
点云SLAM4 个月前
Windows CMD(命令提示符)中最常用的命令汇总和实战示例
windows·microsoft·visual studio·powershell·cmd命令提示符·bat文件·win环境批处理
等不到来世4 个月前
npm : 无法加载文件 C:\Program Files\nodejs\npm.ps1
npm·powershell
Ronin-Lotus4 个月前
上位机知识篇---Prompt&PowerShell Prompt
prompt·powershell
Мартин.4 个月前
Operation Blackout 2025: Smoke & Mirrors
powershell