The SQL Server policies are part of collection from Microsoft default best practice policies plus additional policies I have written over the year.
The policies typical follow the naming convention of rule check, if the policy passes, means your configuration is correct. If rule fails, an update is required.
I will not belong about how to write policies, but if you need assistance please reach out. I would advice you to make sure policies are limited to SQL checks, I have found checking event logs, WMI calls, etc. can be very expensive.
How to deploy policies?
- Connect to Central Management Server (CMS).
- Go to Management.
- Go to Policy Management.
- Go to Policies > Right Click on Policies.
- Select Import Policies.
- In the Dialogbox Open, click on the “…” to navigate to working directory where policies extracted (e.g. C:\Temp\SQLOpDB_Solution_V3.00.00.0000\SQL Policies\). Select all the XML files in one go.
- Select “Replace duplicate with item imported”.
- Click OK.
Once imported you should see all the policies and their respective conditions loaded. Note all policies default to disable and should remain disabled.
The policies are broken into five categories by default. Therefore any new policy must be assigned to these categories for it to be evaluated.
- Database Configuration
- Server Configuration
- Performance [currently not evaluated]
If you wish to modify the categories, introduce new ones, or enable Performance category. You will need to update the “C:\SQLOpsDB\PowerShell\EPM\EPMExecution.ps1” PowerShell script.
Copy line #25 and paste it below, updating the “PolicyCategoryFilter” value to “Performance”.
No environment is perfect, nor they can follow 100% of the best practice configurations.
There is no exception to the rule that every rule has an exception.James Thurber
You can modify the policies for every exception. However, on large environments you will find this a very tedious and difficult task. If you do modify the policies, it will lower the data collection. However, I find the effort is not worth it.
Therefore, my solution reports against policies by checking custom table (Policy.PolicyExclusion). There is no PowerShell script for this. For each policy, server instance, or object you do not want reported in dashboard. You can create a custom exclusion.
“Auto Create Statistics is Disabled” or “Auto Update Statistics is Disabled”. These policies are valid in 90% of the cases. If the SQL Server instance or database is for SharePoint. These policies are invalid. There is no easy way to identify all SharePoint databases.
Therefore, we can create an exclusion for the SQL Instance where all SharePoint databases might be deployed.
INSERT INTO Policy.PolicyExclusions (Policy_ID, EvaluatedServer, ObjectName, ReasonForExclusion) VALUES (20, 'SharePoint\Inst01', '%', 'SharePoint defaults to Auto Create Stats OFF') INSERT INTO Policy.PolicyExclusions (Policy_ID, EvaluatedServer, ObjectName, ReasonForExclusion) VALUES (21, 'SharePoint\Inst01', '%', 'SharePoint defaults to Auto Updates Stats OFF')
Currently only available via T-SQL. Your policy ID might be different, review msdb.dbo.syspolicy_policies for actual ID values.