none
get-process with username, but only include ID, Name, Path RRS feed

  • Question

  • I'm stuck with a bit of an issue, I need a one line statement in powershell to give me, the process ID, Name, Path, and Userid

    now I know Get-process | Select-Object Id,Name,Path works for part of it

    there is also the get-process -IncludeUserName

    but I'm unsuccessful in getting this to work together.

    can someone show me the way

    Thank you!


    Paul Arbogast

    Wednesday, April 12, 2017 5:44 PM

Answers

  • Does this work?

    Get-Process -IncludeUserName | Select-Object Id,Name,Username,Path


    • Marked as answer by parbogast Wednesday, April 12, 2017 7:06 PM
    Wednesday, April 12, 2017 7:02 PM

All replies

  • What makes you think it won't work?


    \_(ツ)_/

    Wednesday, April 12, 2017 6:06 PM
  • well, it wont work, because it doesn't work lol it just returns the ID Name and Path, but no username.


    Paul Arbogast

    Wednesday, April 12, 2017 6:16 PM
  • THs:

    get-process -IncludeUserName

    returns the user name.  Just look more closely at the output.

    D:\scripts> get-process -IncludeUserName

    Handles      WS(K)   CPU(s)     Id UserName               ProcessName
    -------      -----   ------     -- --------               -----------
        117       1792     0.09   9540 ALPHA\xxxxxxx          AccelerometerSt
        452      19080     0.34  10996 ALPHA\xxxxxx          ApplicationFrameHost
        235       3232     0.11   7152 NT AUTHORITY\SYSTEM    armsvc


    \_(ツ)_/

    Wednesday, April 12, 2017 6:32 PM
  • Yes it does, I know that works, but that data is not what I need, I need just the ID, Name and Path of the process along with the UserName

     like the information you get when you do

    Get-Process | Select-Object Id, name,path

    except also include the username


    Paul Arbogast

    Wednesday, April 12, 2017 6:45 PM
  • If you only want the name, id and path then why are you asking for the UserName?  What you are asking makes no sense.  Think about it.  You ask for id, name and path but also want to use -IncludeUserName.  Why ask for user name and then not use it?

    Think....


    \_(ツ)_/

    Wednesday, April 12, 2017 6:51 PM
  • Get-Process -IncludeUserName | Select-Object Id,Name,Username,Path

    • Proposed as answer by jrv Wednesday, April 12, 2017 6:59 PM
    Wednesday, April 12, 2017 6:56 PM
  • Ok maybe I'm not making myself clear

    This is a sample of what I want to get returned back to me

                                                       
    Process ID Name Path Owner
    800 CcmExec.exe C:\Windows\CCM\CcmExec.exe SYSTEM
    1904 conhost.exe C:\WINDOWS\system32\conhost.exe SYSTEM
    2392 conhost.exe C:\WINDOWS\system32\conhost.exe SYSTEM

    Are we on the same page yet? the -IncludeUserName tag provides the owner of the process.


    Paul Arbogast

    Wednesday, April 12, 2017 6:59 PM
  • What is it that you are calling an Owner?  A process runs under a user or system account.  There is no Owner.


    \_(ツ)_/

    Wednesday, April 12, 2017 7:01 PM
  • Does this work?

    Get-Process -IncludeUserName | Select-Object Id,Name,Username,Path


    • Marked as answer by parbogast Wednesday, April 12, 2017 7:06 PM
    Wednesday, April 12, 2017 7:02 PM
  • That is exactly what I needed, so just including the Username in the select-object did the trick. Thank you!

    Paul Arbogast

    Wednesday, April 12, 2017 7:07 PM
  • By Owner I meant the user associated with the process, but Jason helped and saw what I was missing.

    Thanks anyway.


    Paul Arbogast


    • Edited by parbogast Wednesday, April 12, 2017 7:08 PM
    Wednesday, April 12, 2017 7:08 PM
  • Yes. the -IncludeUserName parameter adds the UserName property to the returned objects. Simply selecting it along with the other properties you need will display it.

    I did find that if it was the last property in the list (e.g. Select-Object Id,Name,Path,UserName) it wouldn't display. I don't know why this is, but changing the order worked.

    Wednesday, April 12, 2017 7:09 PM
  • Because it is too wide for the screen:

    Get-Process  -IncludeUserName |select id,name,path,username| Format-List


    \_(ツ)_/

    Wednesday, April 12, 2017 7:12 PM
  • Yeah I did not see that UserName property, thanks so much!

    Paul Arbogast

    Wednesday, April 12, 2017 7:17 PM