我如何验证一个进程是否已经在 powershell 上 运行?

How can i verify if a process is already running on powershell?

我有以下代码

Start-Process -windowstyle minimized "C:/xampp/xampp-control.exe"

有一种方法可以知道进程是否已经 运行?

一种方法是获取进程的进程ID(使用Start-Process-PassThru参数),然后可以通过ID查看进程是否存在。示例:

$processId = (Start-Process notepad -PassThru).Id
if ( Get-Process -Id $processId -ErrorAction SilentlyContinue ) {
   "Process is running"
}