I know this question has been asked in the past, but a satisfactory answer has not been provided.
I am using the SC command to config the credentials for a service.<
To enable log on as a service via script I've written this, you can use it as is or pull out what is useful to you
https://raw.githubusercontent.com/cdaf/windows/master/automation/provisioning/setServiceLogon.ps1