如何将 Windows 服务设置为在 PowerShell 中自动启动?

Geo*_*ge2 5 powershell windows-services

如果我知道服务名称并拥有足够的权限,如何在 PowerShell 中将 Windows 服务设置为自动重启?

我使用的是 PowerShell 1.0,操作系统是 Windows Server 2003。

Ste*_*ham 5

您可能会要求:

Set-Service [service name] -startuptype automatic
Run Code Online (Sandbox Code Playgroud)

看:

> get-help set-service

NAME
    Set-Service

SYNOPSIS
    Starts, stops, and suspends a service, and changes its properties.


SYNTAX
    Set-Service [-StartupType {Automatic | Manual | Disabled}] [-DisplayName <string>] [-PassThru] [-Status <string>] [
    -InputObject <ServiceController>] [-Description <string>] [-ComputerName <string[]>] [-confirm] [-whatif] [<CommonP
    arameters>]

    Set-Service [-Status <string>] [-StartupType {Automatic | Manual | Disabled}] [-Description <string>] [-Name] <stri
    ng> [-PassThru] [-DisplayName <string>] [-ComputerName <string[]>] [-confirm] [-whatif] [<CommonParameters>]
Run Code Online (Sandbox Code Playgroud)

  • 用于设置服务分层模式。但我想,George 想配置服务崩溃时自动重启。 (7认同)