I'm trying to create and start a windows service using PowerShell.
The service is created but cannot be started when I use various names besides one particular name.
When I create the service with the name of the exe file it can be started but when I give it a different name it fails to start.
I'm running the PowerShell script as administrator.
Any advises?
function InstallService(
[string] $MsDeployHost,
[string] $ServiceName,
[string] $DisplayName,
[string] $ServicePath,
[string] $ServiceDescription,
[object] $Credential) {
if($MsDeployHost -eq "local") {
New-Service -name $ServiceName -binaryPathName $ServicePath -displayName $ServiceName -StartupType Automatic
Start-Service -name $ServiceName
} else { ....
The Error I get: Start-Service : Service 'Service1 (Service1)' cannot be started due to the following error: Cannot start service Service1 on computer '.'.
When I try to start it manually I get: "Error 1053: The service did not respond to the start or control request in a timely fashion"