无法停止服务 - 使用 Powershell 停止远程 Windows 服务时出错
Service Cannot Be Stopped - Error stopping remote Winodws Service using Powershell
我有一个简单的脚本 stops/starts 远程服务器上的多个服务。它工作正常,但每隔 运行 我都看到以下错误。但即使它说它无法停止服务,实际上它也停止了它。我尝试在不同服务之间添加一些暂停时间,但这似乎无济于事。
这是停止服务的方式
Get-Service -ComputerName SERVER1 -Name SERVICE1 | Stop-Service -Force
这是一个完整的错误
Stop-Service : Service 'SERVICE1 (SERVICE1)' cannot be stopped due to the following error: Cannot
stop SERVICE1 service on computer 'SERVER1'.
At C:\Script\dev1_stop.ps1:25 char:67
+ ... puterName SERVER1 -Name SERVICE1 | Stop-Service -Force
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (System.ServiceProcess.ServiceController:ServiceController) [Stop-Service],
ServiceCommandException
+ FullyQualifiedErrorId : CouldNotStopService,Microsoft.PowerShell.Commands.StopServiceCommand
我会说这可能是特定于服务 and/or 及其依赖项的东西。由于我不熟悉 "SERVICE1",所以我真的无法提供更好的回复。您可能会查看故障主机的系统事件日志。
我有一个简单的脚本 stops/starts 远程服务器上的多个服务。它工作正常,但每隔 运行 我都看到以下错误。但即使它说它无法停止服务,实际上它也停止了它。我尝试在不同服务之间添加一些暂停时间,但这似乎无济于事。
这是停止服务的方式
Get-Service -ComputerName SERVER1 -Name SERVICE1 | Stop-Service -Force
这是一个完整的错误
Stop-Service : Service 'SERVICE1 (SERVICE1)' cannot be stopped due to the following error: Cannot
stop SERVICE1 service on computer 'SERVER1'.
At C:\Script\dev1_stop.ps1:25 char:67
+ ... puterName SERVER1 -Name SERVICE1 | Stop-Service -Force
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (System.ServiceProcess.ServiceController:ServiceController) [Stop-Service],
ServiceCommandException
+ FullyQualifiedErrorId : CouldNotStopService,Microsoft.PowerShell.Commands.StopServiceCommand
我会说这可能是特定于服务 and/or 及其依赖项的东西。由于我不熟悉 "SERVICE1",所以我真的无法提供更好的回复。您可能会查看故障主机的系统事件日志。