When I first started using Powershell scripting to monitor and report on SQL Server Error Logs - I used to use the script on Powershell_ErrorLogs. Since then I've made some adjustments , adding email send functionality, sql query change, and stylesheet functionality set-location E:\health\SQL_Server $isodate=Get-Date -format s $isodate=$isodate -replace(":","") $basepath=(Get-Location -PSProvider FileSystem).ProviderPath $serverpath=$basepath + "\config\instances_prod.txt" $outputfile="\logs\sql_server_health_SQL_Server_Logs_" + $isodate + ".html" $outputfilefull = $basepath + $outputfile $emailFrom = "jack@sqlserver_dba.com" $emailTo = "[email protected]" $subject = "SQL Server Logs Critical in the last 24 hrs - Prod " $body = "SQL Server Logs Critical in the last 24 hrs - Prod " $smtpServer...
Read more →