如何使用 PowerShell 获取远程计算机上的服务?
powershellmicrosoft technologiessoftware & coding
要获取远程计算机上的服务,只需添加参数 – ComputerName 并提供远程服务器的计算机名称或 IP 地址即可。
在下面的示例中,我们将获取远程计算机 Win7 的服务信息,该计算机的启动类型为 Automatic。
Get-Service -ComputerName Win7 | Where{$_.StartType -eq "Automatic"}
同样,您可以在 – ComputerName 参数中连接多台计算机,并用逗号 (,) 分隔。
Get-Service -ComputerName Win7, TestPC |其中{$_.StartType -eq "Automatic"}
如果您需要识别服务存在于哪些特定的计算机上,可以使用 machinename 属性。在上面的示例中,我们在 Pipeline 中添加了机器名称属性。
Get-Service -ComputerName Win7, TestPC | Where{$_.StartType -eq "Automatic"} |
Select MachineName, Name, Status

