httpdが起動しているかどうかプロセスで確認する方法です。
Get-Process | Where-Object { $_.ProcessName -like “a*”}
だとaが頭についている名前を表示する。
httpdという名前のプロセスを表示するには
以下のようにする。
Get-Process | Where-Object { $_.ProcessName -like “httpd”}
・実行すると以下のように表示された。
PS C:\Windows\system32> Get-Process | Where-Object { $_.ProcessName -like “htt
d”}
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
——- —— —– —– —– —— — ———–
3052 26 20356 27620 110 25.90 5056 httpd
3466 88 46168 50384 207 35.71 8232 httpd
さらに、プロセス数の数を表示するには以下のようにする。
(Get-Process | Where-Object { $_.ProcessName -like “htt
pd”} ).Count
▼実行例
PS C:\Windows\system32> (Get-Process | Where-Object { $_.ProcessName -like “htt
pd”} ).Count
2