How to get PID of an EXE file from Windows command line

How do I get the PID of an EXE file from Windows command line?

I want to query the PID from the command line, rather than manually search in Task Manager.

I've found something similar in nix


PowerShell Get-Process can return the PID of running processes.

❯ Get-Process explorer

 NPM(K)    PM(M)      WS(M)     CPU(s)      Id  SI ProcessName
 ------    -----      -----     ------      --  -- -----------
    135   218.04     218.04     140.12   34304   3 explorer

❯ (Get-Process explorer).Id
34304

Documentation