在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/網(wǎng)絡(luò)安全/ Powershell 如何使用Invoke-RestMethod下載網(wǎng)頁文件?

Powershell 如何使用Invoke-RestMethod下載網(wǎng)頁文件?

Powershell腳本使用Invoke-RestMethod訪問API下載文件,下載的文件和網(wǎng)頁操作的不一樣。
腳本如下:

$today = Get-date 
$trgFldr="D:\"
$fileNm = $today.ToString('yyyyMMdd')+".rpd"
$fileNm = $trgFldr+$fileNm  

$userNm='ussern'
$passwd='sadadaf' | ConvertTo-SecureString -asPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($userNm,$passwd) 

$Server = "127.0.0.1"
$Port   = "9502"
$uri = "http://${server}:${port}/bi-lcm/v1/si/ssi/rpd/downloadrpd"
$postParm = "target-passwd=welcome1"
Invoke-RestMethod -Uri $uri -Method POST -Body $postParm -Credential $cred -OutFile $fileNm  
回答
編輯回答
尛曖昧

查看輸出文本內(nèi)容,發(fā)現(xiàn)有反饋信息,說是沒接收到參數(shù)值,檢查后發(fā)現(xiàn)是POST參數(shù)名寫錯(cuò)了。
修改$postParm = "target-password=welcome1"后,成功保存文件。

2017年4月13日 20:05