Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Find process owner of multiple processes

$
0
0

The following 2 lines of code work.  But when I try to get the name of the process it returns nothing.

$owners = get-process | Select-Object name, company 

foreach ($owner in $owners) {if ($owner -like '*Sybase*') { write-host "got it" $owner}} 

----------------------------------------------------------------

This is not working.  I've tried many things for the Write-Host and I get no errors.  Just no output.

$owners = get-process | Select-Object name, company 

foreach ($owner in $owners) {if ($owner -like '*Sybase*') { Write-Host $_owner.name}} 

What I'm trying to do is this.   We have a suite of tools that has 10 .EXEs.  In Taskman if you view the properties of these .EXEs they are all owned by Sybase.    I want to find all running processes owned by Sybase and then kill them.    This is so we can then copy new .EXE's into the needed folder.


Viewing all articles
Browse latest Browse all 6937

Trending Articles