I’m attempting to deploy a service I created… However, when it is ran as System (as part of an install script), it fails with the error “Cannot start service from the command line or a debugger. A Windows Service must first be installed (using installutil.exe) and then started with the ServerExplorer, Windows Services Administrative tool or the NET START command.”
The command I’m using is…
& “.\Service.exe” --install
I get this error when I try to install it via PSRemoting as well. If I RDP into a machine, I can install it just fine.
If you could post a complete step-by-step on how to reproduce the issue (that way there’s no need for guessing) with the minimal code then I (and probably others) can try to recreate this and see if we can help.
@DataTraveler@Jori - If we just updated the documentation to suggest New-Service over the --install parameter would that make sense? I have to imagine it’s attempting to perform a similar operation.
Awesome. It is a bummer that Remove-Service isn’t available in 5.1…
Out of curiosity, I imported the Microsoft.PowerShell.Management module from Powershell 7 into 5.1 and Remove-Service DID work… But if I had access to Powershell 7 on these machines I wouldn’t have been trying the --install and --uninstall.