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.
Read more on Powerhsell and Windows
Disaster Recovery Powershell Script to check for failed Windows services
Get Last Windows boot up time with Powershell
This is only a preview. Your comment has not yet been posted.
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.
Posted by: |