用 Restart-Service 重启 Windows 服务

在 PowerShell 中停止、启动、重启服务,一行命令替代 services.msc 或 net stop/start。

Windows服务PowerShell中风险
以管理员运行 Restart-Service -Name <服务名> -Force 一步完成停止并启动,用 Get-Service 查看状态。

01命令

命令
$ Restart-Service -Name wuauserv -Force
Get-Service -Name wuauserv | Select-Object Name, Status, StartType

02作用说明

Restart-Service 会原子地完成先停后启,-Force 还会一并重启依赖该服务的服务——用 net stop 的话得先手动列出依赖。Get-Service 支持通配符秒查(Get-Service *audio*),还能看到 StartType;要改启动类型得用 Set-Service -StartupType,Start-Service 做不到。经典场景是 Windows 更新卡住时重启 wuauserv 或 BITS。

03风险

风险中风险
使用条件Run PowerShell as administrator for services that are not user-managed
!注意: 重启服务会中断正在使用它的程序——更新进行中重启 wuauserv、或重启数据库服务,都可能让工作处于不一致状态。

04撤销

撤销
$ Start-Service -Name wuauserv

05来源

  • Restart-Service - SS64
    SS64 · technical · 2026-09-17
    依据: Shows Restart-Service usage and pipeline patterns with Get-Service.
  • Restart-Service
    Microsoft Learn · vendor-doc · 2026-09-17
    依据: Documents Restart-Service including -Force for dependent services.

最后验证: 2026-09-17 · 分类: 系统与设置

06相关方案