Set-Service

 

Additional Resources for Set-Service

 

Modifying the Properties of a Service

http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/set-service.mspx

 

 

SYNOPSIS

Changes the display name, description, or starting mode of a service.

 

SYNTAX

Set-Service [-name] <string> [-displayName <string>] [-description <string>] [-startupType {<Automatic> | <Manual> | <Disabled>}] [-whatIf] [-confirm] [<CommonParameters>]

 

DETAILED DESCRIPTION

The Set-Service cmdlet changes the properties of a service, including the description, display name, and start type. You can specify the services by their service names or display names.

 

PARAMETERS

 

-name <string>

Specifies the service names of the services to be changed. Wildcards are permitted. The parameter name is optional. You can use "-Name" or its alias, "-ServiceName", or you can omit the parameter name.

 

Required?

true

Position?

1

Default value

 

Accept pipeline input?  

true (ByValue, ByPropertyName)

Accept wildcard characters? 

false

 

-displayName <string>

Specifies a new display name for the cmdlet.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-description <string>

Specifies a new description for the service.

 

The service description appears in Services in Computer Management. Description is not a property of the ServiceController object that Get-Service retrieves, but the Win32_Service WMI class includes a description property. To retrieve instances of that class, use the Get-WMIObject cmdlet.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-startupType <ServiceStartMode>

Changes the starting mode of the service. Valid values for StartupType are:

 

·          Automatic: Start when the system starts.

·          Manual   : Starts only when started by a user or program.

·          Disabled : Cannot be started.

 

The following lists the acceptable values for this parameter:

 

·          Automatic

·          Manual

·          Disabled

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-whatIf

Describes what would happen if you executed the command without actually executing the command.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-confirm

Prompts you for confirmation before executing the command.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, and -OutVariable. For more information, type, "get-help about_commonparameters".

 

NOTES

 

For more information, type "Get-Help Set-Service -detailed". For technical information, type "Get-Help Set-Service -full".

 

When specifying multiple values for a parameter, use commas to separate the values. For example, "<parameter-name> <value1>, <value2>".

 

Set-Service can control services only when the current user has permission to do so. If a command does not work correctly, you might not have the required permissions.

 

To find the service names and display names of the services on your system, type "get-service". The service names appear in the "Name" column and the display names appear in the "DisplayName" column.

 

EXAMPLE 1

 

set-service -name lanmanworkstation -DisplayName "LanMan Workstation"

 

This command changes the display name of the lanmanworkstation service to "LanMan Workstation" (the default is "Workstation"). It uses the Name parameter to identify the service that is being changed and the DisplayName parameter to specify a new display name for the service.

 

EXAMPLE 2

 

get-wmiobject win32_service -filter "name = 'SysmonLog'"

 

set-service sysmonlog -startuptype automatic

 

get-wmiobject win32_service -filter "name = 'SysmonLog'"

 

These commands get the start type of the Performance Logs and Alerts (SysmonLog) service, set the start type to automatic, and then display the result of the change.

 

The first command uses the Get-WmiObjectcmdlet to get the WMI object that represents the SysmonLog service. The default output of this command displays the start type of the service in the "StartMode" field. The second command uses Set-Service to change the start mode to automatic. Then, the first command is repeated to display the change.

 

To display the start type of all services on the computer, type "get-wmiobject win32_service | format-table Name, StartMode -autosize".

 

EXAMPLE 3

 

set-service -name Schedule -description "Configures and schedules tasks."

 

get-wmiobject win32_service | where-object {$_.Name -eq "Schedule"} | format-list Name, Description

 

These commands change the description of the Task Scheduler service on the computer, and then display the result.

 

The first command  uses a Set-Service command to change the description. It identifies the service by using the service name of the service, "Schedule".

 

The second command uses the Get-WmiObjectcmdlet to get an instance of the WMI Win32_Service that represents the Task Scheduler service. The first element in the command gets all instances of the Win32_service class. The pipeline operator (|) passes the result to the Where-Objectcmdlet, which selects instances with a value of "Schedule" in the name property. Another pipeline operator sends the result to the Format-Listcmdlet which formats the output as a list with only the Name and Description properties.

 

RELATED LINKS

Get-Service

Start-Service

Stop-Service

Restart-Service

Resume-Service

Suspend-Service

New-Service