Skip to content

Extend Process with CommandLine property  #3322

Closed

Description

Add a CodeMethod to extend System.Diagnostics.Process with CommandLine to be able to see how a process was started.

Activity

  1. added
    Issue-Enhancement
    Up-for-Grabs
    on Mar 13, 2017
  2. rkeithhill commented on Mar 27, 2018

    @rkeithhill
    Collaborator

    Yes, please. This would be really useful to have!

  3. lzybkr commented on Mar 27, 2018

    @lzybkr
    Contributor

    For a quick and easy Windows only solution, after running:

    Install-Module NtObjectManager

    Add the following to your profile to get CommandLine and ParentProcessId:

    Update-TypeData -TypeName System.Diagnostics.Process -MemberType ScriptProperty -MemberName CommandLine -Value {
        (Get-NtProcess -ProcessId $this.Id).CommandLine
    }
    Update-TypeData -TypeName System.Diagnostics.Process -MemberType ScriptProperty -MemberName ParentProcessId -Value {
        (Get-NtProcess -ProcessId $this.Id).ParentProcessId
    }

    This way is much faster than using CIM.

  4. rkeithhill commented on Mar 27, 2018

    @rkeithhill
    Collaborator

    Sweet find!! Thanks.

  5. rkeithhill commented on Mar 27, 2018

    @rkeithhill
    Collaborator

    Ah, man ... be still my beating heart:

    Get-ExecutableManifest $pshome\powershell.exe
    
    
    ParseError     : False
    FullPath       : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    Name           : powershell.exe
    UiAccess       : False
    ExecutionLevel : asInvoker
    AutoElevate    : False
    ManifestXml    : <assembly xmlns="urn:schemas-microsoft-com:asm.v1"
                       manifestVersion="1.0">
                       <description>PowerShell</description>
                       <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
                         <security>
                           <requestedPrivileges>
                             <requestedExecutionLevel
                               level="asInvoker"
                               uiAccess="false" />
                           </requestedPrivileges>
                         </security>
                       </trustInfo>
    ...
    
  6. tlsalex commented on Jul 29, 2019

    @tlsalex

    no update from ms?

  7. iSazonov commented on May 31, 2020

    @iSazonov
    Collaborator

    Fixed for Windows and Linux.
    #12832 is tracking this for MacOs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-EnhancementResolution-FixedUp-for-GrabsWG-Cmdlets

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions