Starts Powershell scripts as service in windows
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
PowershellStarter Added New-PowershellStarterService.ps1 that automatically changes the… May 27, 2017
License.md Create License.md Jun 13, 2017
PowershellStarter.sln 2nd sync May 26, 2017
README Create README Jun 13, 2017

README

I wanted something that would run powershell scripts as a service easily and I never was a fan of running it with taskscheduler.
This windows service reads the path of the script and it's arguments from the app.conf file so you can run any powershell script that you want (i think).
It also redirects output and errors to eventlog and terminates itself if the script would stop running.
Link to Github
I have tested it on Windows Server 2012 and Windows 10.
 
Tutorial

Start with downloading the current compile (link above) or compile it yourself and put it some place good.
Open PowershellStarter.exe.config in notepad
Edit ScriptPath to point to your powershell script.
Edit ScriptParameters or leave it empty if you don't have any parameters.
You can edit Eventlog and EventlogSource if you have any special preference on how you want to log it.
Start powershell as admin and enter:
New-Service -Name PowershellStarter -DisplayName PowershellStarter -BinaryPathName C:\Path\To\PowershellStarter.exe -Description "Powershellstarter service" -StartupType Automatic
"Powershellstarter" can be any name you want.
And finally:
Start-Service PowershellStarter
Done!
If anything messes up it should be visible under the application eventlog.

*MIT License*

Copyright (c) 2017 Alex Asplund

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.