Sunday, January 26, 2014

Powershell: Deploying Windows Service remotely

As a big adherent of Continuous Integration practice I often need to deploy a Windows Service on an another computer remotely "by click".

Mostly, this task is performed from our TeamCity Build Server and consists of the following steps:

  • Stopping remote Windows Service
  • Backuping it's files
  • Copying new files into the remote folder where the service is
  • Starting remote Windows Service
It's very easy to accomplish these steps using Powershell:
  • Get-WmiObject cmdlet is used for managing Windows Service remotely
  • Robocopy tool is used for "smart" copying files into remote shared folder
If you are interested you can find the simplified script example on GitHub