【问题标题】:Service Cannot Be Stopped - Error stopping remote Winodws Service using Powershell无法停止服务 - 使用 Powershell 停止远程 Windows 服务时出错
【发布时间】:2019-05-07 10:21:17
【问题描述】:

我有一个简单的脚本,可以停止/启动远程服务器上的多个服务。它工作正常,但每隔一次运行我都会看到以下错误。但即使它说它不能停止服务,实际上它也会停止它。我尝试在不同服务之间添加一些暂停时间,但这似乎没有帮助。

这就是它停止服务的方式

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

【问题讨论】:

    标签: powershell windows-services


    【解决方案1】:

    我会说它可能是特定于服务和/或其依赖项的东西。由于我不熟悉“SERVICE1”,因此我无法提供更好的响应。您可以查看故障主机上的系统事件日志。

    【讨论】:

    • 谢谢!你是对的 - 这是我在事件日志中发现的:SERVICE1 服务的停止方法未能运行,服务正在被终止。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多