Source of Windows Processes (Task Manager) Command Line Property?

Hello,

I’m failing to do what should be simple, determine the command line property of a running process just like ‘Windows Task Manager’ displays when adding the command line column/property (I would put in a screen shot at this point but no idea how!).

I’m particularly interested in knowing how my various java process are performing but I cannot tell one java process from another, as they just say “java.exe”… not helpful. I have tried the following:

Get-WmiObject Win32_Process -Filter "name = 'java.exe'" | Select-Object -Property name, CommandLine
and
Get-Process -name java | Select-Object -Property name, CommandLine
In both cases I get only the process name (java or java.exe) and nothing for the command line. I'm new to PowerShell so please don't dismiss the obvious, can anyone help explain why I'm not able to determine the command line details when they must surely be there somewhere?

Thanks a lot.

Get-CimInstance Win32_Process | Where-Object -Property Name -Match -Value Java | Select-Object Name,CommandLine

Hello again Olaf,

Thanks for coming to my rescue once more, and again it was a combination of things. I ran your command and got exactly the same result, process name but no command line details which got me thinking.

So I opened PowerShell as ‘Administrator’ and ran the same command, bingo!! In fact the ‘Get-WmiObject’ I tried also works as administrator (get-process just doesn’t do it but no bother) suggesting that Windows Task Manager must run as administrator somehow without me asking.

Thanks again for your help, I’ll run these scripts as Administrator from now on. Cheers.