In this article, you will learn how to check if a Windows Service is running and restart if not, in TimeXtender Orchestration and Data Quality. Many applications use Windows Services for background jobs and in some cases, they might be unstable. For example, an unstable point of sales (POS) service could stop all transactions while down, and requires manual interventions by IT people.
With TimeXtender Orchestration and Data Quality, you can automatically monitor and restart these services, reducing the manual work of remoting and restarting. In addition, it will keep a log of all instances helping IT to pinpoint and audit these failures.
Create a control in TimeXtender Orchestration and Data Quality
- Create a Query with a PowerShell data provider
- Add the following code
$serviceName = '{@servicename[preview:exMon Command Service]}' $service = Get-Service -Name $serviceName | select Displayname,Status,@{label="NewStatus";expression={$_.Status}},@{label="Hostname";expression={[System.Net.Dns]::GetHostName()}} if ($service.Status -ne 'Running') { # The service is stopped. Restart and fetch new status Start-Service $serviceName $service.NewStatus = (Get-Service -Name $serviceName | select Status).Status $service } else { $timeXtenderResult= New-Object system.Data.DataTable $col1 = New-Object system.Data.DataColumn DisplayName,([string]) $timeXtenderResult.columns.add($col1) $col2 = New-Object system.Data.DataColumn Status,([string]) $timeXtenderResult.columns.add($col2) $col3 = New-Object system.Data.DataColumn NewStatus,([string]) $timeXtenderResult.columns.add($col3) $col4 = New-Object system.Data.DataColumn Hostname,([string]) $timeXtenderResult.columns.add($col4) #return empty results when everything is OK $timeXtenderResult }
- Run the query and configure the control as normally.
- Note that you can select a specific machine to run the query on by creating a specific PowerShell data provider, connected to a specific Execution Connection.
- Deploy the control
You can then list each service by adding it to a Schedule Group, Object Group, or Process by adding parameters as shown below:

Here is an example of output for the control
