I am trying to find a way to check if a specific processs exists on about 200 computers. Right now i am doing this using the command tasklist (get-process doesnt work on some of the computers) but this takes about 3-4 minutes which causes my gui to freeze. How can i multi-thread this check?
You are looking for jobs.
In your particular case:
$scriptBlock = {
Get-Process -Name 'SomeProcessName'
}
foreach ($computer in $200Computers)
{
Invoke-Command -ComputerName $computer -ScriptBlock $scriptBlock -AsJob
}
$jobs = Get-Job
# other code goes here.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.