PowerShell Logo Small

New-Service



This is the built-in help made by Microsoft for the command 'New-Service', in PowerShell version 2 - as retrieved from Windows version 'Microsoft® Windows Vista™ Ultimate ' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Creates a new Windows service.

SYNTAX


New-Service [-Name] <string> [-BinaryPathName] <string> [-Credential <PSCredential>] [-DependsOn <string[]>] [-Description <string>] [-DisplayNam
e <string>] [-StartupType {Automatic | Manual | Disabled}] [-Confirm] [-WhatIf] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The New-Service cmdlet creates a new entry for a Windows service in the registry and in the service database. A new service requires an executabl
e file that executes during the service.

The parameters of this cmdlet let you set the display name, description, startup type, and dependencies of the service.



<

RELATED LINKS

Online version: http://go.microsoft.com/fwlink/?LinkID=113359
Get-Service
Start-Service
Stop-Service
Restart-Service
Resume-Service
Set-Service
Suspend-Service

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

C:\PS>new-service -name TestService -binaryPathName "C:\WINDOWS\System32\svchost.exe -k netsvcs"



Description
-----------
This command creates a new service named "TestService".








-------------------------- EXAMPLE 2 --------------------------

C:\PS>new-service -name TestService -path "C:\WINDOWS\System32\svchost.exe -k netsvcs" -dependson NetLogon -displayName "Test Service" -StartupTy
pe Manual -Description "This is a test service."



Description
-----------
This command creates a new service named "TestService". It uses the parameters of the New-Service cmdlet to specify a description, startup type,
and display name for the new service.

To specify the BinaryPathName parameter, the command uses the Path parameter alias. You can also use "-bpn".








-------------------------- EXAMPLE 3 --------------------------

C:\PS>get-wmiobject win32_service -filter "name='testservice'"

ExitCode : 0
Name : testservice
ProcessId : 0
StartMode : Auto
State : Stopped
Status : OK



Description
-----------
This command uses the Get-WmiObject cmdlet to get the Win32_Service object for the new service. This object includes the start mode and the servi
ce description.