【PowerShell】用 Invoke-WebRequest -Uri 傳送 POST 資料

創造一個 post 資料的陣列
{name=value;name2=value}
$postParams = @{project='all_project';post=1}
然後用 Invoke-WebRequest -Uri 取得回覆
$result = Invoke-WebRequest -Uri http://domain/test.php -Method POST -Body $postParams -OutFile .\test.html -PassThru
-Method 設定成 POST
-Body 放要傳送的陣列
-OutFile 讓他把回應寫成檔案

留言