PowerShell service redeployment script
A PowerShell script to work around Windows Server limitations.
More information
Imagine having a Jenkins pipeline that deploys a new .war, .ear or .jar file to a server. How do you stop the application service once that happens, redeploy this file to the application server and then start it again, with the new application version?
What I did
I needed to solve this problem, so I whipped out some PowerShell and got to work. I managed to achieve the desired results with some functionality to watch when files in a given directory change and the rest was also pretty easy to do - it turns out that using PowerShell is actually a pretty decent development experience, in some regards even better than the Bash or other equivalents on Linux.
What I learnt
This was actually my first serious experience with writing PowerShell scripts, which I'd describe as an overall pleasant one. That said, it's odd that Windows Server doesn't provide anything that's as easy to work with as the systemd service mechanism - there exists an alternative, but it's not as nice to use or automate.