如何'only'在Windows中获取服务'status'? (“systemctl is-active service”的替代方案)

How to 'only' get the service 'status' in Windows? (alternative for `systemctl is-active service`)

我一直在探索 windows 替代方法以遵循 Linux 命令:

systemctl is-active firewalld

此命令仅向我们提供字符串 activeinactive 作为输出。从而对开发各种脚本有所帮助。

到目前为止,我无法为 windows 找到这样的命令。你能帮忙吗?

Powershell:

$serviceName = "firewalld"
(get-service $serviceName).status

将 return Running/Stopped/Deactivated 如果存在名为“firewalld”的服务。