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