notify when sql service is restarted

  • Today when I check sql log in management studio, I notice sql server services is restarted in the log.

    Is there a way that I can be notified when sql services is stopped and started or is restarted and better yet to tell me who did it?

    Thanks

  • yes, actually it is my next Simple-Talk article and I am showing hot to send an email too, and you can use Powershell for this 🙂

    #SQLServiceStop

    $query = "select * from __InstanceModificationEvent within 5 where TargetInstance ISA 'Win32_Service' and TargetInstance.Name='MSSQLSERVER' and TargetInstance.State='Stopped'"

    #Register WMI event

    Register-WMIEvent -Query $query -Action {Write-Host "Hey..hey..wakeup Man. Your SQL Server service stops"}

    I have blog post on my blog about this 🙂

    Hey PowerShell Eventing, can you notify me … when SQL Server Service stop ?[/url]

    This solution you need a windows posh open and if the server is restarted the event is close. But I am working on a solution using Permanent event, in other words , these limitations do not happens.

    $hell your Experience !!![/url]

  • Thanks, also any way to find out who stop(start) or restart it?

    What I often see is sometimes when I check the sql log I found SQL server was restarted for example previous day. I didn't get an notification.

    I just want to know someone restarted the service at approximately when and who did it?

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply