none
What drive has the executable file that is launched for a specific process RRS feed

  • General discussion

  • I am using this command structure to try to find the drive that an executable is launched for a specific process:

    (get-process explorer).Path.split('\')[0] but have found that if there are more than one executable running (for say something like svchost) and the SI is 0 for that particular executable that Powershell will display an error that there is a null value. Is there a way to ignore the null value and only see the  executables that have actual values?


    • Edited by DougAncil2018 Thursday, June 7, 2018 4:48 PM
    • Changed type Bill_Stewart Monday, July 30, 2018 1:44 PM
    • Moved by Bill_Stewart Monday, July 30, 2018 1:44 PM Unanswerable drive-by question
    Thursday, June 7, 2018 2:38 PM

All replies

  • Enumerate to get the da-TA.

    get-process svchost | ForEach-Object{($_.Path -split '\\')[0]}


    \_(ツ)_/

    Thursday, June 7, 2018 2:44 PM
  • Is there a way to further parse that to remove all of the blank space within the response back from Windows?
    Thursday, June 7, 2018 7:07 PM
  • Magic works::

    ('\\xxxx\xxxx\xxx').Split('\\',[System.StringSplitOptions]::RemoveEmptyEntries)


    \_(ツ)_/

    Thursday, June 7, 2018 7:23 PM
  • What is it you really want to know? (Tell what you want to do, not how you think it needs to be done.)

    -- Bill Stewart [Bill_Stewart]

    Thursday, June 7, 2018 9:14 PM
  • JRV .... how does that full powershell script look? I can't get what you suggested to work.
    Friday, June 8, 2018 1:23 PM
  • I refer the honorable gentleman to the question I already posted.

    -- Bill Stewart [Bill_Stewart]

    Friday, June 8, 2018 1:43 PM
  • Bill,

    I am trying to see the output of Get-Process and to parse that information so I can remove all of the blank space in the results that are displayed.

    get-process svchost | ForEach-Object{($_.Path -split '\\')[0]}

    That shows all of the results that I need, but blank space is displayed as well. I would just like to clean that up. 

    Friday, June 8, 2018 2:33 PM
  • You seem to be misunderstanding a fundamental point of how PowerShell works.

    The output of Get-Process is not text; it is process objects. The on-screen display is just a default display that contains some of the properties of those objects.

    You will probably need to read the previous sentence several times. Let it sink in.

    What properties of the process objects are you looking for? What information do you want?


    -- Bill Stewart [Bill_Stewart]

    Friday, June 8, 2018 2:48 PM
  • Bill,

    I want the disk that is processing the application and then displaying those objects in a readable format. As I stated the other command displays the objects that I need to see, but also displays blank space before it shows the objects. 

    Friday, June 8, 2018 2:59 PM
  • If the process is running with a share as the default drive then there is no drive.  The blank spaces are because there is not "Path" property.  Just filter the blank ones out.

    I posted the solution to leading blanks in a name when one exisits:

    ('\\xxxx\xxxx\xxx').Split('\\',[System.StringSplitOptions]::RemoveEmptyEntries

    To remove all blank paths then do this:

    get-process svchost | Where{$_.Path} | ...


    \_(ツ)_/

    Friday, June 8, 2018 3:14 PM
  • So then the final code should look something like this?

    get-process svchost | Where{($_.Path).Split('\\',[System.StringSplitOptions]::RemoveEmptyEntries)}

    Friday, June 8, 2018 3:45 PM
  • Your statement makes little sense.

    Why don't you give an example command that you are using and the output you are seeing, and then explain why the output is not suitable. Also post what the output should look like.


    -- Bill Stewart [Bill_Stewart]

    Friday, June 8, 2018 3:46 PM
  • So then the final code should look something like this?

    get-process svchost | Where{($_.Path).Split('\\',[System.StringSplitOptions]::RemoveEmptyEntries)}

    No.  You must use the full pipeline syntax. The "Where" will just filter out all blank paths and pass them down the line.


    \_(ツ)_/


    • Edited by jrv Friday, June 8, 2018 3:52 PM
    Friday, June 8, 2018 3:52 PM
  • Please post an example command and explain what information you want to see.


    -- Bill Stewart [Bill_Stewart]

    Friday, June 8, 2018 4:59 PM
  • My output looks like this:

    C:

    C:

    C:

    with all of the blank space above it. I want to clean that up so that I don't see any of the blank space.

    Friday, June 8, 2018 7:02 PM
  • My output looks like this:

    C:

    C:

    C:

    with all of the blank space above it. I want to clean that up so that I don't see any of the blank space.

    The "Where" in the pipeline will filter the blanks.


    \_(ツ)_/

    Friday, June 8, 2018 7:36 PM
  • What command is generating that output? (Remember: Nobody can see your screen!)

    -- Bill Stewart [Bill_Stewart]


    Friday, June 8, 2018 8:40 PM