Powershell 在执行Invoke-Restmethod时,如何在日志文件中显示完整的消息;“多点/点数据”;
我有一个Powershell脚本,它有一个调用RestMethod代码,用于通过API将文件发送到URL 代码如下所示Powershell 在执行Invoke-Restmethod时,如何在日志文件中显示完整的消息;“多点/点数据”;,powershell,api,logging,Powershell,Api,Logging,我有一个Powershell脚本,它有一个调用RestMethod代码,用于通过API将文件发送到URL 代码如下所示 [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 -bor [System.Net.SecurityProtocolType]::Tls11 -bor [System.Net.SecurityProtocolType]::Tls;
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 -bor [System.Net.SecurityProtocolType]::Tls11 -bor [System.Net.SecurityProtocolType]::Tls;
Invoke-RestMethod -Method POST -ContentType "multipart/form-data" -Uri $Uri -InFile $FilePath >> $Log
现在,在将返回响应附加到“Log”文件时,我得到以下格式
success data
------- ----
True @{created=0; updated=0; skipped=0; unchanged=19; uploaded=19; errors=0; statusUrl=https://sandbox.myurl.com/Services/Conta...
URL不完整。此返回消息生成为不完整
我需要下面的格式
谁能帮我把这件事搞起来
谢谢下面的代码成功了
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 -bor [System.Net.SecurityProtocolType]::Tls11 -bor [System.Net.SecurityProtocolType]::Tls;
$response = Invoke-RestMethod -Method POST -ContentType "multipart/form-data" -Uri $Uri -InFile $FilePath
$response
$response.success >> $Log
$response.data >> $Log
$response.numRows >> $Log
$response[0] >> $Log
当我记录响应时,我不得不使用>>$Log来附加日志文件我不认为mesage是不完整的,只是被截断了。尝试用
|Format List
或|Format Table-Wrap
替换>$Log
,以完整查看状态URL。