How to get process id by its service name with a script to variable

前端 未结 6 1358
闹比i
闹比i 2021-01-01 13:37

I have service named WinDefend and it runs on process svchost.exe
There other many svchost.exe processes and I need to find a way

6条回答
  •  臣服心动
    2021-01-01 14:35

    $p=Tasklist /svc /fi "SERVICES eq windefend" /fo csv | convertfrom-csv
    $p.PID
    

提交回复
热议问题