Evaluating a policy
In this recipe, we will evaluate a policy against our SQL Server instance.
Getting ready
In this recipe, we will evaluate the xp_cmdshell must be disabled
policy, which we created in a previous recipe. We also want to export this to an XML file and there are two different ways of evaluating the policy. Use the Exporting a policy recipe to export the xp_cmdshell must be disabled
policy and save it in C:\Temp
. Alternatively, you can perform the following steps:
- Log in to SQL Server Management Studio.
- Go to Management | Policy Management and select Policies.
- Right-click on the xp_cmdshell must be disabled policy and select Export Policy.
- Save this policy in
C:\Temp
.
Feel free to substitute this with a policy that is available in your instance.
How to do it...
These are the steps required to evaluate a policy using PowerShell:
- Open PowerShell ISE as an administrator.
- Import the
SQLPS
module and create a new SQL Server object as follows:#import SQL Server module Import-Module SQLPS...