In this recipe, we will list policies deployed in our SQL Server instance.
Check which policies are being used in your environment using SQL Server Management Studio. Connect to SSMS and navigate to Management | Policy Based Management | Policies:
These are the same policies you should get after you run the PowerShell script in this recipe.
How to do it...
To list policies using PowerShell, perform the following steps:
- Open PowerShell ISE as an administrator.
- Import the
SQLPSmodule as follows:
#import SQL Server module Import-Module SQLPS -DisableNameChecking
- Add the following script and run it:
#replace with your server information ...
Get SQL Server 2014 with PowerShell v5 Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.