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

相关推荐
点云SLAM1 个月前
Windows CMD(命令提示符)中最常用的命令汇总和实战示例
windows·microsoft·visual studio·powershell·cmd命令提示符·bat文件·win环境批处理
等不到来世1 个月前
npm : 无法加载文件 C:\Program Files\nodejs\npm.ps1
npm·powershell
Ronin-Lotus1 个月前
上位机知识篇---Prompt&PowerShell Prompt
prompt·powershell
Мартин.1 个月前
Operation Blackout 2025: Smoke & Mirrors
powershell
墨雪遗痕2 个月前
中文Windows系统下程序输出重定向乱码问题解决方案
rust·编码·powershell
粉色挖掘机2 个月前
PowerShell批量处理文件名称/内容的修改
powershell
noravinsc2 个月前
powershell 获取 用户及进程列表
windows·powershell
struggle20253 个月前
LazyOwn RedTeam/APT 框架是第一个具有人工智能驱动的 C&C 的 RedTeam 框架
c语言·开发语言·python·html·powershell
Moshow郑锴3 个月前
Powershell : Transfer yesterday‘s EOD file to SMB folder
powershell
.格子衫.3 个月前
powershell批处理——io校验
测试·powershell