$Machine = ''; $Machine =~ s{^[\\/]{2,}}{}; my $CLASS = 'WinMgmts:{impersonationLevel=impersonate}!//' . $Machine; my $WMI = Win32::OLE->GetObject($CLASS) or die Win32::OLE->LastError(); foreach my $proc (in $WMI->InstancesOf('Win32_Process')){ print "$proc->{'Name'}" . " | " . "$proc->{'ProcessId'}\n"; $where = index($searchString, $proc->{'Name'}); if ($where > -1) { UpdateLogFile("$searchString running"); last; } }