我需要使用IP地址重新启动LAN计算机的服务。我对此进行了研究:
Restart-Service -ComputerName \\10.10.11.16 -ServiceName IETCQRService dnsCache
这是我得到的错误:
Restart-Service : A parameter cannot be found that matches parameter name 'ComputerName'. At line:1 char:17 + Restart-Service -ComputerName \\10.10.11.16 -ServiceName IETCQRServic ... + ~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Restart-Service], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.RestartServiceCommand
我需要使用IP地址,因为计算机名称相同,只是IP地址不同。
编辑 我已经使用了建议,但是现在出现此错误:
PS C:\WINDOWS\system32> Get-Service -ComputerName 10.10.11.16 -Name "IETCQRService" | Restart-Service Get-Service : Cannot find any service with service name 'IETCQRService'. At line:1 char:1 + Get-Service -ComputerName 10.10.11.16 -Name "IETCQRService" | Restart ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (IETCQRService:String) [Get-Service], ServiceCommandException + FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand
答案 0 :(得分:1)
据我所知,Restart-Service命令上没有-ComputerName参数。相反,您可以使用以下内容:
Get-Service -ComputerName 10.10.11.16 -Name "IETCQRService" | Restart-Service
您可以在Get-Service命令中使用IP地址或计算机名称
注意,正如评论中指出的那样,此选项不可行,因为该选项已从PowerShell 6+版本中删除。