使用 REST 與 PowerShell 物件來獲取和釋出許多專案

獲取 REST 資料並儲存在 PowerShell 物件中:

$Users = Invoke-RestMethod -Uri "http://jsonplaceholder.typicode.com/users"

修改資料中的許多項:

$Users[0].name = "John Smith"
$Users[0].email = "John.Smith@example.com"
$Users[1].name = "Jane Smith"
$Users[1].email = "Jane.Smith@example.com"

POST 所有 REST 資料:

$Json = $Users | ConvertTo-Json
Invoke-RestMethod -Method Post -Uri "http://jsonplaceholder.typicode.com/users" -Body $Json -ContentType 'application/json'