- This topic has 2 replies, 2 voices, and was last updated 2 weeks, 5 days ago by
May 13, 2020 at 9:50 am #227716ParticipantTopics: 2Replies: 8Points: 61Rank: Member
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
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.
May 13, 2020 at 10:22 am #227731ParticipantTopics: 4Replies: 2247Points: 5,484Rank: Community MVP
Get-CimInstance Win32_Process | Where-Object -Property Name -Match -Value Java | Select-Object Name,CommandLine
May 13, 2020 at 11:53 am #227755ParticipantTopics: 2Replies: 8Points: 61Rank: Member
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.
- You must be logged in to reply to this topic.