Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend Process with CommandLine property #3322

Closed
powercode opened this issue Mar 13, 2017 · 7 comments · Fixed by #12288
Closed

Extend Process with CommandLine property #3322

powercode opened this issue Mar 13, 2017 · 7 comments · Fixed by #12288
Labels
Issue-Enhancement the issue is more of a feature request than a bug Resolution-Fixed The issue is fixed. Up-for-Grabs Up-for-grabs issues are not high priorities, and may be opportunities for external contributors WG-Cmdlets-Management cmdlets in the Microsoft.PowerShell.Management module

Comments

@powercode
Copy link
Collaborator

powercode commented Mar 13, 2017

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

@SteveL-MSFT SteveL-MSFT added WG-Cmdlets-Management cmdlets in the Microsoft.PowerShell.Management module Issue-Enhancement the issue is more of a feature request than a bug Up-for-Grabs Up-for-grabs issues are not high priorities, and may be opportunities for external contributors labels Mar 13, 2017
@SteveL-MSFT SteveL-MSFT assigned powercode and unassigned powercode Oct 1, 2017
@rkeithhill
Copy link
Collaborator

rkeithhill commented Mar 27, 2018

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

@lzybkr
Copy link
Member

lzybkr commented Mar 27, 2018

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.

@rkeithhill
Copy link
Collaborator

rkeithhill commented Mar 27, 2018

Sweet find!! Thanks.

@rkeithhill
Copy link
Collaborator

rkeithhill commented Mar 27, 2018

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>
...

@tlsalex
Copy link

tlsalex commented Jul 29, 2019

no update from ms?

@iSazonov
Copy link
Collaborator

iSazonov commented May 31, 2020

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

@msftbot
Copy link

msftbot bot commented Jun 25, 2020

🎉This issue was addressed in #12288, which has now been successfully released as v7.1.0-preview.4.🎉

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement the issue is more of a feature request than a bug Resolution-Fixed The issue is fixed. Up-for-Grabs Up-for-grabs issues are not high priorities, and may be opportunities for external contributors WG-Cmdlets-Management cmdlets in the Microsoft.PowerShell.Management module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants