Creates a new Windows service. (New-Service)

   

# NAME
New-Service

# SYNOPSIS
Creates a new Windows service.

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

# 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 executable 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.

# PARAMETERS
-BinaryPathName <string>
Specifies the path to the executable file for the service. This parameter is required.

Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Credential <PSCredential>
Specifies a user account that has permission to perform this action. Type a user name, such as "User01" or "Domain01\User01". Or, enter a PSCredential object, such as one from the Get-Credential cmdlet. If you type a user name, you will be prompted for a password.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-DependsOn <string[]>
Specifies the names of other services upon which the new service depends. To enter multiple service names, use a comma to separate the names.

Required? false
Position? named
Default value None
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

-DisplayName <string>
Specifies a display name for the service.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Name <string>
Specifies the name of the service. This parameter is required.

Required? true
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false

-StartupType <ServiceStartMode>
Sets the startup type of the service. "Automatic" is the default.

Valid values are:

-- Manual: The service is started only manually, by a user (using the Service Control Manager) or by an application.

-- Automatic: The service is to be started (or was started) by the operating system, at system start-up. If an automatically started service depends on a manually started service, the manually started service is also started automatically at system startup.

-- Disabled: The service is disabled and cannot be started by a user or application.

Required? false
Position? named
Default value Automatic
Accept pipeline input? false
Accept wildcard characters? false

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-WhatIf [<SwitchParameter>]
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

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

# INPUTS
None
You cannot pipe input to this cmdlet.

# OUTPUTS
System.ServiceProcess.ServiceController
New-Service returns an object that represents the new service.

# NOTES

To run this cmdlet on Windows Vista and later versions of Windows, start Windows PowerShell with the "Run as administrator" option.

# 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" -StartupType 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 service description.

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

C:\Windows>powershell get-help Set-Content -full

ColorConsole [Version 1.7.1000] PowerShell 2.0-Export
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2014 Microsoft Corporation.

OS: Windows 10, 8.1, 8, 7, Vista / Windows Server 2016, 2012, 2008
»»»» ColorConsole





... Home  
... Impressum
... ColorConsole

... CMD
... Netsh-XP
... Netsh-7
... Netsh-Vista
... Powershell










Download the Windows 10 Starter, Home (Basic Premium), Professional und Ultimate!

... facebook.de
HTTP: ... PS_Windows/en/New-Service.htm
0.125

In Windows 8.1 den linken Bildschirmecke-Umschalter deaktivieren!

 /

How to start Windows-7 Run-Dialog (find, open)?

 /

Was ist ein Mausrad?

 /

Zum Programmstart einstellen, dass die PCs zu einem bestimmten Zeitpunkt heruntergefahren werden!

 /