I have to launch several times an executable with different argument each time and I need to get back the process ID for each of them.
I have the used command line and I need the process ID of the process started with this command.
Following some others question here I have found this:
Get-CimInstance Win32_Process -Filter "name = 'evolution4.exe'" | select CommandLine
Which can give me the command Line use for the process started, but I now need to do a filter on the CommandLine and not on the name and Select the PID.
I tried replacing "name" by "commandLine" or "CommandLine" without result and I don't even know if it's the proper way to do. What should I put in my filter ? Does this command can be filtered by command line instead of name or pid ?
Edit: It seems that my problem is more about giving a path in the string of the filter than the argument which seems to be "commandLine" as I thouht.
Nevermind : Answer was simple
Path must be set with double '\'.
Which lead to :
Get-CimInstance Win32_Process -Filter "commandLine = 'C:\\Windows\\Explorer.exe'" | Select ProcessId