How to get Command Line info for a process in PowerShell or C#

In PowerShell you can get the command line of a process via WMI:

$process = "notepad.exe"
Get-WmiObject Win32_Process -Filter "name="$process"" | Select-Object CommandLine

Note that you need admin privileges to be able to access that information about processes running in the context of another user. As a normal user it’s only visible to you for processes running in your own context.

Leave a Comment