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 policy xp_cmdshell must be disabled
, which we created in a previous recipe. We also want to export this to an XML file, so we can see two different ways of evaluating the policy. Use the Exporting a policy recipe to export the policy xp_cmdshell must be disabled
and save it in C:\Temp
. Alternatively you can:
Log in to SQL Server Management Studio.
Go to Management | Policy Management and expand Policies.
Right-click on the policy xp_cmdshell must be disabled, 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...
Open the PowerShell console by going to Start | Accessories | Windows PowerShell | Windows PowerShell ISE.
Import the
SQLPS
module, and create a new connection object as follows:#import SQL Server module Import-Module SQLPS -DisableNameChecking $instanceName...