dbatools is a free PowerShell module with over 200 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Get-DbaPolicy

Returns details of policies with the option to filter on Category and SystemObjects.

Screenshots

dbatools-Get-DbaPolicy

Examples

Returns all policies from sql2016 server.

Get-DbaPolicy -SqlInstance sql2016

Uses a credential $cred to connect and return all policies from sql2016 instance.

Get-DbaPolicy -SqlInstance sql2016 -SqlCredential $cred

Returns all policies from sql2016 server that part of the PolicyCategory MorningCheck.

Get-DbaPolicy -SqlInstance sql2016 -Category MorningCheck

Author

This command was created by Stephen Bennett. You can find Stephen on his blog.

Get-Help

From PowerShell, execute Get-Help Get-DbaPolicy -Detailed for more information on this function.

Source Code

Want to see the source code? View Get-DbaPolicy.ps1 on GitHub
 

Related commands