[Solved] how to get a pc list that have a service running on each pc?


If all computers have powershell installed with remoting enabled, you can try the script below. It also outputs computers that were not reachable so you can retest them later if you want to. If you don’t need it, just remove the content inside the catch-block(or all of try/catch):

$out = @()
Get-Content "pclist.txt" | foreach {
    $pc = $_ 
    try {
        if((Get-Process -Name "pmill" -ComputerName $pc) -ne $null) {
            $out += $_
        }
    } catch { 
        #Unknown error
        $out += "ERROR: $pc was not checked. $_.Message"
    }
}

$out | Set-Content "out.txt"

pclist.txt:

graimer-pc
pcwithoutprocesscalledpmill
testcomputer
testpc
graimer-pc

Out.txt (log):

graimer-pc
ERROR: testcomputer is unreachable
ERROR: testpc is unreachable
graimer-pc

11

solved how to get a pc list that have a service running on each pc?