How To Check SQL Windows Services Stopped Time And Who Stopped with powerhsell

13 March,2021 by Tom Collins

Question:  I want to create  a report using Powershell where the Stop & Start times of SQL Server related windows services are reported. As well as the username (if available)

Answer:  The  Powerhsell Get-EventLog cmdlet is one method to get these results. There are other ways - but the flexibility for piping and access to the logs is far more effective.

This example will return a Grid view with 3 columns : message , timegenerated, user, with a filter on the  keyword "SQL"


get-eventlog -source "Service Control manager" -LogName System | select-object message,timegenerated,user|Where-Object{$_.message -like "*SQL*"}| Out-GridView

 

This is the sort of output to expect . You can elect to not use the Out-GridView - but the output will be displayed on the Powershell console.

Out-gridview

 

Read more on Powerhsell and Windows

Disaster Recovery Powershell Script to check for failed Windows services

Get Last Windows boot up time with Powershell

 

 


Author: Tom Collins (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on How To Check SQL Windows Services Stopped Time And Who Stopped with powerhsell


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer