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?
Asked
Active
Viewed 149 times
0
-
1Possible duplicate of [Can Powershell Run Commands in Parallel?](https://stackoverflow.com/questions/4016451/can-powershell-run-commands-in-parallel) – Brandon McClure Nov 23 '19 at 18:27
1 Answers
0
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.

KUTlime
- 5,889
- 1
- 18
- 29