| 用途 | 规模化执行与负载控制 |
|---|---|
| 远程 | Invoke-Command -ThrottleLimit 32(默认) |
| 本机并行 | ForEach-Object -Parallel -ThrottleLimit(PS7+) |
常用示例
常用示例
$hosts = 1..50 | ForEach-Object { "node$_" }
Invoke-Command -ComputerName $hosts -ThrottleLimit 10 -ScriptBlock { Get-Service WinRM | Select-Object Status }
# PowerShell 7 本机并行
1..10 | ForEach-Object -Parallel { Start-Sleep -Seconds 1; $_ } -ThrottleLimit 5对生产系统做变更要“先限流后提速”:小批量成功→评估→分批推进。