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

相关推荐
zjx238818 天前
使用 PowerShell 脚本 + FFmpeg 在 Windows 系统中批量计算 MP4视频 文件的总时长
powershell
DogDaoDao18 天前
从零开始:Windows 系统中 PowerShell 配置 FFmpeg 的详细步骤
windows·ffmpeg·音视频·ffplay·powershell·视频直播·ffprobe
三巧1 个月前
判断按键盘是否好使的开机自启动PowerShell脚本
计算机外设·powershell
一夜空中最亮的星一2 个月前
【Windows】PowerShell 缓存区大小调节
windows·缓存·powershell·ps·windows 终端
安冬的码畜日常2 个月前
【工欲善其事】利用 DeepSeek 实现复杂 Git 操作:从原项目剥离出子版本树并同步到新的代码库中
git·ai·powershell·cherry-pick·deepseek·deepseek r1·deepseek v3
Eastmount3 个月前
[论文阅读] (36)C&S22 MPSAutodetect:基于自编码器的恶意Powershell脚本检测模型
论文阅读·系统安全·powershell·自编码器·恶意代码检测
H轨迹H4 个月前
一文学会powshell使用及功能
网络安全·渗透测试·powershell·红队全栈
tiandyoin4 个月前
删除 C 盘空文件夹--递归删除
脚本·batch·powershell·空文件夹
JUNIOR_MU4 个月前
【VMware VCF】管理 VCF 环境中组件的密码策略。
powershell·vcf·vmware cloud foundation·powervcf·password management·password policy·password expiration·password complexity·account lockout
Ztiddler4 个月前
【CMD、PowerShell和Bash设置代理】
开发语言·深度学习·github·bash·powershell·代理·cmd