Powershell 我是否可以使用Invoke WebRequest将二进制数据写入文件并仍然获取状态代码?

Powershell 我是否可以使用Invoke WebRequest将二进制数据写入文件并仍然获取状态代码?,powershell,download,Powershell,Download,但是,我需要使用POST请求下载文件,因为PowerShell似乎无法处理管道和变量中的二进制数据(Out file不支持二进制数据),所以我需要使用Invoke WebRequest的-OutFile参数。但是,执行此操作时,它不再输出状态代码,因此我可以将其捕获到变量中: PS K:\hmpf>$Filepath=“E:\shmimpf\g\yyv.fgr” PS K:\hmpf>$URL=”https://wwwh.ipswich.org/tycobrahe/magazine.php?bu

但是,我需要使用POST请求下载文件,因为PowerShell似乎无法处理管道和变量中的二进制数据(
Out file
不支持二进制数据),所以我需要使用
Invoke WebRequest
-OutFile
参数。但是,执行此操作时,它不再输出状态代码,因此我可以将其捕获到变量中:

PS K:\hmpf>$Filepath=“E:\shmimpf\g\yyv.fgr”
PS K:\hmpf>$URL=”https://wwwh.ipswich.org/tycobrahe/magazine.php?burgerflipcount=76"
PS K:\hmpf>(调用WebRequest-Uri$URL-OutFile$Filepath-Method Post)。状态码
PS K:\hmpf>(调用WebRequest-Uri$URL-Method Post)。状态码
200
PS K:\hmpf>
来自:

因此,要结合
-OutFile
获得响应结果:

(调用WebRequest-Uri$URL-OutFile$Filepath-Method Post-PassThru)
-PassThru

    Indicates that the cmdlet returns the results, in addition to writing them to a file. 
    This parameter is valid only when the OutFile parameter is also used in the command.