小编use*_*214的帖子

从 Powershell 发布时如何解析“内容”输出?

所以我有一些简单的代码,它遍历本地驱动器上的一些 JSON 文件,并将它们发布到带有 cURL 的 URL:

$negativeTests = Get-ChildItem "C:\Users\ME\Documents\folder\folder\"
#Write-Host $negativeTests;
for ($i = 0; $i -lt $negativeTests.Count; $i++) {
    $tempFile = Get-Content $negativeTests[$i].PSPath
    Invoke-WebRequest -Uri https://myWebsite.com/ext/ext/ext -Method POST -Body $tempFile
}
Run Code Online (Sandbox Code Playgroud)

此代码在运行时将以以下格式提供服务器的输出:

StatusCode        : 304
StatusDescription : OK
Content           : {"success":NO,"errors":[ERROR],"stuffs":100}
RawContent        : HTsP/5.1 42 OK
                    X-f-Options: oasdf
                    Connection: keep-alive
                    Content-Length: 234
                    Cache-Control: no-cache
                    Content-Type: application/???; charset=ut480a
                    Date: Tue, 29 Jun 2060 11:72:83 GMT
                    S...
Forms             : {}
Headers           : {[X-Frame-Options, SAMEORIGIN], [Connection, keep-alive], [Content-Length, 52], [Cache-Control, no-cache]...} …
Run Code Online (Sandbox Code Playgroud)

powershell curl

1
推荐指数
1
解决办法
5220
查看次数

标签 统计

curl ×1

powershell ×1