A SQL Server Daily Health Check Script with Powershell is very effective in checking databases. I implement this health check script early in the morning , generating a report and emailed to the DBA team. The Powershell script iterates through a list of SQL Server Instances and executes the sql script.

Data is critical to many business processes. Continuous access to the data is one of the key objectives of a DBA. A build up of many small problems can lead to a SQL Server outage. It’s important to fix small problems in a timely fashion. Part of fixing the problem, is to define a clear set of policies, and check regularly that the policies are met. Check SQL Server - Powershell and SQL Error Logs

The purpose of the Report is to check on various organisational policy conditions . It’s different to the Monitoring alert system, which triggers an alert when a situation arises. It assists in creating housekeeping tasks . For example , if it’s a policy to not allow isAutoShrink , then this sql statement returns the isAutoShrink status of every database.

Another condition maybe to check if the Data and Log files are maintained on separate drives. This SQL Script will check and return a flag to indicate the Data and Log Files are on the same drive.

Customise the sql code to satisfy the goals you’re trying to achieve in managing the SQL Server Inventory.

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 + " -->"