Posts

Showing posts with the label windows service

How to: Create a Windows Service Kickstarter using Powershell

Since some legacy Windows services are getting more and more unstable and fall apart without any means of recovery, a kickstarter is needed to ensure those important(?) services don't just disappear quietly without any struggle. The idea is to use a combination of Powershell script and Task Scheduler to trigger the job every now and then. 0. Precondition The Windows Server 2003 R2 does not come with Powershell installed. To allow Powershell scripts to run on the machine, follow the link to download and install it, and bear in mind, system reboot will NOT be required. 1. Powershell Script Powershell is really easy to pick up. It only requires basic knowledge of Command Prompt, and the rest is just C#. function ServiceKickstarter($serverName, $serviceName) {       $service = Get-Service -ComputerName $serverName -Name $serviceName     if ($service.Status -eq "Stopped")     {         ...

How to: Remotely start/stop/monitor windows services

When working with a lot of different servers, to monitor and control the windows services on those machines can be a real pain. Because you either need to RDP to the machine or open a remote services session. In order to automate the tedious hard labour and achive this in bulk. I used the remote command 'SC' to access NT Service Contoller provided by MS. The syntax is as simple as the following: for monitoring service: sc <server-name> query <spooler or any service name> for stopping service: sc <server-name> stop <spooler or any service name> for starting service: sc <server-name> start <spooler or any service name> List all the servers and put them in .bat file, that way would save you a great deal of time repeating yourselves. FYI, the SC command details are listed below:     The option <server> has the form "\\ServerName"     Further help on commands can be obtained by typing: "sc [command]"  ...