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

To reference the "smtp.ps1" - create a new powershell file and place the function found on : Send email from Powershell with attachment . You don't need to keep the file in the modules folder , you can place the file in the same folder and reference. You are passing certain values into this function , including the reference to the attachment , which is added to the email

To reference the "stylesheet.ps1" - create a new powershell file with that name , and place in code similar to: $reportstyle="<!-- TABLE{border-width: 2px;border-style: solid}" $style=$style + "TD{border-width: 2px;border-style: solid}" $style=$style + " -->"