New-Service

 

SYNOPSIS

Creates a new entry for a Windows Service in the registry and the Service Database.

 

SYNTAX

New-Service [-name] <string> [-binaryPathName] <string> [-displayName <string>] [-description <string>] [-startupType {<Automatic> | <Manual> | <Disabled>}] [-credential <PSCredential>] [-dependsOn <string[]>] [-whatIf] [-confirm] [<CommonParameters>]

 

DETAILED DESCRIPTION

Creates a new entry for a Windows Service in the registry and the Service Database. The cmdlet lets you set the display name, description, startup type and dependencies of the service.

 

PARAMETERS

 

-name <string>

Specifies the name of the service.

 

Required?

true

Position?

1

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-binaryPathName <string>

Specifies the path to the executable file for the service.

 

Required?

true

Position?

2

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-displayName <string>

Specifies the display name for the service.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-description <string>

Specifies a description of the service.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-startupType <ServiceStartMode>

Sets the startup type of the service.

 

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

 

-credential <PSCredential>

Specifies the credential the service will start under.

 

Required?

false

Position?

named

Default value

LocalSystem

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-dependsOn <string[]>

Names of other services upon which the new service depends. Separate multiple service names by using a comma.

 

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".

 

INPUT TYPE

None

 

RETURN TYPE

ServiceControllerObject

 

NOTES

 

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

 

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

 

EXAMPLE 1

 

new-service testservice "C:\WINDOWS\System32\svchost.exe -k netsvcs"

 

This command creates a new entry in the registry and Service Database for a service named "testservice".

 

RELATED LINKS

Get-Service

Start-Service

Stop-Service

Restart-Service

Resume-Service

Set-Service

Suspend-Service