We have a server in production that requires SQLSERVERAGENT service to be restarted exactly at 2:30am *IF* it's at stopped state. (sometimes the DBA would stop the service after hours do to some migration effort)
With that, I created and deployed a batch file with "Net Start SQLSERVERAGENT" command and uses Scheduled Task Policy to call the file at 2:30am.
However, most of the time, the service is always running, and the policy still executes itself at 2:30am (of course, it does not pose any impact nor do anything, because it has already running)
Is there a command to add to the batch file in order to tell the policy only executes at 2:30am IF the service isn't running??