Issue setting service startup type
Closed this issue · 4 comments
Trying to ensure that SQL Express service is started and set as Automatic. This commands works fine when in a PS1 file:
Get-Service mssql | Set-Service –StartupType Automatic
When I convert the PS1 file to an EXE using PS2EXE, then run it I get the following error:
ERROR: A positional parameter cannot be found that accepts argument 'Automatic'.
I double-checked that was I was running as Administrator, so there shouldn't be permissions issues. I also added "#Requires -RunAsAdministrator" to the top of the script.
Not sure if this is a bug or if there is a workaround for this.
Thanks.
Hello @rvernon9,
please exchange your "wrong" dash (ASCII Code 0x96) with the correct one (ACSII Code 0x2d) in -StartupType.
PS2EXE is not as generous with syntax errors as the Powershell, be careful when copying code out of a browser or Word.
Greetings
Markus
Thanks for the reply @MScholtes
Looks like that fixed the issue! Thank you!
I assume that the issue has been solved.