Get-Process $pid should suggest using -Id $pid
See original GitHub issueThe default parameter set for Get-Process
accepts -Name
by position.
Maybe it’s just me, but I forget this all the time, and expect Get-Process 1234
to work.
I think we can make it work in a reasonable way too. If Name is a positive integer and we do not find a process by that name, search again assuming it was a ProcessId.
Edit: instead of making this work (which might not be a good idea always) - I like the suggestion from @rkeithhill to give a better error message.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:24 (12 by maintainers)
Top Results From Across the Web
Get-Process (Microsoft.PowerShell.Management)
Specifies one or more processes by process ID (PID). To specify multiple IDs, use commas to separate the IDs. To find the PID...
Read more >How to Find Process ID (PID and PPID) in Linux
Learn how to find PID using a process name in Linux. ... If you know the exact process name, you can get its...
Read more >Get a process ID - linux
Get a process ID · I have to filter my output using grep commands. Examples: ps -ef | grep user | grep info1...
Read more >How to Find Process Name from its PID
You can list all running process using the ps command or top command and note the process ID and process name as desired....
Read more >Run a process to particular/dedicated pid only
I have a c program executable or shell script which I want to run very often. If I want to stop/pause or to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Agreed. At the very least, the error message could say
Cannont find a process with the name "1234". If 1234 is a process Id, use Get-Process -Id 1234.
Of course, you would only use that error message when the Name parameter value is all digits.Just to add to this, where this particular issue drives me the most is that Stop-Process uses a default parameter set that requires Id rather than name. I always try something like this first:
Then I sigh, then I re-run the command, explicitly using the -Name parameter.
I would much prefer if this set of commands simply had a consistent rule among them that made ad-hoc use more palatable.