Importing a policy
This recipe will show you how you can import a policy stored as an XML file into SQL Server.
Getting ready
In this recipe, we will use an XML policy that comes with the default SQL Server installation. This policy is called Database Page Verification.xml and is stored in C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Policies\DatabaseEngine\1033
.
Feel free to substitute this with a policy that is available in your system.
How to do it...
These are the steps required to import a policy using PowerShell:
- Open PowerShell ISE as an administrator.
- Import the
SQLPS
module:#import SQL Server module Import-Module SQLPS -DisableNameChecking
- Add the following script and run it:
$connectionString = "server='localhost';Trusted_Connection=true" #set up connection $conn = New-Object Microsoft.SQlServer.Management.Sdk.Sfc.SqlStoreConnection($connectionString) #NOTE this is still called DMF, which stands for #PBM's old name, Declarative Management Framework ...