show process's full command line in powershell?

Viewed 13477

When I run this command

PS C:\> gwmi Win32_Process | select CommandLine

It cuts off the command line. How can I get it to show the full command line?

enter image description here

4 Answers

You're better off filtering for specific process which can be done via PID or Process Name, both pieces of information are easily obtained from the task manager if you don't already know.

Once you have the PID this will work great:

$PID=<Your Process ID)

(Get-WmiObject win32_process -Filter ProcessId=$PID -Property CommandLine).CommandLine

Example of getting java.exe by process name: (Get-WmiObject -Class win32_process -Filter "Name='java.exe'" -Property CommandLine).CommandLine

added by barlop

example with output-

PS C:\Users\User> (Get-WmiObject win32_process -Filter ProcessId=1676 -Property CommandLine).CommandLine <ENTER>

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --type=renderer --field-trial-handle=1108,1777349067310493
8616,10462310811264875730,131072 --lang=en-GB --enable-auto-reload --origin-trial-disabled-features=MeasureMemory --devi
ce-scale-factor=1 --num-raster-threads=2 --enable-main-frame-before-activation --renderer-client-id=1695 --no-v8-untrust
ed-code-mitigations --mojo-platform-channel-handle=11412 /prefetch:1
PS C:\Users\User>

This is a frequently asked question about how powershell formats output. Aside from making the window bigger:

gwmi Win32_Process | % CommandLine

sihost.exe
C:\Windows\system32\svchost.exe -k UnistackSvcGroup
taskhostw.exe {222A245B-E637-4AE9-A93F-A59CA119A75E}
Related