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

时间:2009-08-02 13:34:12

标签: powershell windows-services

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

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

1 个答案:

答案 0 :(得分:4)

您可能会要求:

Set-Service [service name] -startuptype automatic

请参阅:

> 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>]