Closed Lichtsinnig closed 4 years ago
That is not something that is handled by the PowerShell Module.
You would need to do something like this: https://4sysops.com/archives/how-to-run-a-powershell-script-as-a-windows-service/ or more complicated: https://docs.microsoft.com/en-us/archive/msdn-magazine/2016/may/windows-powershell-writing-windows-services-in-powershell
I use the service manager program (ssm.exe) included in SaltStack to do this: cmd /c c:\salt\bin\ssm.exe install {service name} Powershell.exe {path to listener script}\Invoke-RestPSListener.ps1 -RoutesFilePath {path to routes script}\RestPS_Endpoints\Invoke-AvailableRouteSet.ps1 -Port 8081
ssm.exe includes a number of config flags, to set logging, restart options, run as user, etc. I can't locate the documentation at the moment, though.
Thanks @joel74 !!
How do I run restapi as a windows service?