Get Remote Process + user Id and commandline


I recently had to generate a script to find out what process and pid something was on a remote machine I came up with this small powershell function to do just that:

 

function Get-RemoteProcessUser
{
  param
  (
  $Computername,
  $Processname,
  $userName
  )

$process = (Get-WmiObject -ComputerName $Computername -ClassName win32_process -filter "name like '%$Processname%'" | Select-Object Name,@{n='Owner';e={$_.GetOwner().User}}, commandline, creationdate, Processid) | Where-Object{$_.owner -eq $username})
$process
}

 

Short but effective .

 

Keep on Scripting

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s