I need help writing a for-each loop to iterate through all of the processes running on my system. Within the for-each loop, I need to write an IF statement to check if the ID number is greater than 10000. If the ID is greater than 10000, it must display the message “[Process Name] has an ID greater than 10000.” Else, no message needs to be displayed.
I'm a complete newbie to Powershell and I truly cannot figure this one out. Any assistance would be of great help. Here is what I have so far:
$theprocessID = Get-Process | Where-Object -FilterScript {$_.Id -gt 15000}
foreach ($theprocess in $relatedprocess)
{
if ($theprocess -ge 10000)
{$_.computername
write-output "has an ID greater than 1000."}
}
Aucun commentaire:
Enregistrer un commentaire