Skip to main content

Service - Restart

Summary

This script will restart one or more services with proper error handling. It can also be imported and triggered using the Alert Template '△ Custom - Autofix - Restart Service'.

Implementation

These steps must be followed after importing/updating the script after September 5, 2023.

Step 1: Run the script on any online Windows computer. This will create the necessary system properties.

System Properties

System Properties:

System Properties

Step 2: Set the system properties for alerting. Check the System Properties section of the document for more information on the properties.

Sample Run

Manual Execution:

Manual Execution

Dependencies

Variables

NameDescription
STATUSStatus returned from Monitor Set (SUCCESS
FieldNameService name returned from Monitor Set
SubjectTicket/Email subject
BodyTicket/Email body for failure
CommentTicket/Email comment for failure
TicketCommentTicket comment for success
EmailBodyEmail body for success
TicketCreationCategoryNumerical ID of the ticket category to create the ticket. The script will fetch the ticket category from the monitor set running it.
PSCheckTo check the PowerShell version of the computer, the script will perform Automate's inbuilt functions to attempt to restart the service for older operating systems.

User Parameters

NameExampleRequiredDescription
ServiceNames'SAAZDPMACTL', 'SAAZWatchDog', 'SAAZServerPlus', 'SAAZScheduler'True (for manual execution)A string array of service names to restart.
Set_Environment1True (for first run)Set it to 1 to create the required system properties.

System Properties

NameExampleRequiredDescription
Restart_Service_Autofix_Ticketing_Enabled1True1 and 0 to toggle between the ticket creation feature of the script. The default value is 1 (Enabled Ticketing).
Restart_Service_Autofix_Emailing_Enabled0False1 and 0 to toggle between the emailing feature of the script. The default value is 0 (Disabled Emailing).
Restart_Service_Autofix_Send_Success_Email0FalseSet it to 1 to send an email on monitor success as well. The default value is 0. To enable monitor success emails, Restart_Service_Autofix_Emailing_Enabled must be set to 1.
_sysTicketDefaultEmailsupport@provaltech.comTrue (if emailing is enabled)Email address to notify. It is mandatory to set the email address(es) if the system property Restart_Service_Autofix_Emailing_Enabled is set to 1. Multiple email addresses should be separated by a semicolon. Note: Please be careful while making any changes to this property as this is a default system property and other script(s) might be using this as well. Do not update the email address(es) saved in this property without checking the other scripts for this system property.

Ticket Category

The script will fetch the ticket category from the monitor set running the script.

From individual machine:
Individual Machine

From Group Monitor:
Group Monitor

Output

  • Script log (for detailed information on individual results)
  • Tickets (if enabled)
  • Emails (if enabled)