MZI*_*ZIP 6 powershell multithreading ping
我最近完成了一个脚本,用于 ping 列表中的每台计算机/工作站并以良好的格式输出。
有数千台计算机需要 ping 下一个列表,因此需要一段时间才能正常运行。我如何能够对其进行多线程处理,以便可以在合理的时间范围内完成这项工作?
workflow Ping
{
param($computers)
foreach -parallel ($computer in $computers)
{
$status = Test-Connection -ComputerName $computer -Count 1 -Quiet
if (!$status)
{ Write-Output "Could not ping $computer" }
}
}
$computers = @(
"wd1600023",
"sleipnir"
)
Ping $computers
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8323 次 |
| 最近记录: |