我正在尝试获取Windows框中所有正在运行的服务的计数。我跑的时候:
Get-Service | Where-Object {$_.Status -eq "running" }
我获取所有正在运行的服务的列表。但我想使用以下命令计算运行的服务数量,它将计数显示为零。这是错误的计数。我的盒子上运行了20多项服务。
$acoundrunningservices = Get-Service | Where-Object {$_.Status -eq "running"}
$acoundrunningservices.Count
答案 0 :(得分:2)
$acoundrunningservices = Get-Service | Where-Object {$_.Status -eq "running"}
$acoundrunningservices.Count
对我有用,以及:
Get-Service | Where-Object {$_.Status -eq "running" } | Measure-Object | Select-Object Count
或:
(Get-Service | Where-Object {$_.Status -eq "running" }).Count