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-DbaUserLevelPermission

This command will display all server logins, server level securable, database logins and database securables.

DISA STIG implementators will find this command useful as it uses Permissions.sql provided by DISA.

Note that if you Ctrl-C out of this command and end it prematurely, it will leave behind a STIG schema in tempdb.

Screenshots

dbatools - Get-DbaUserLevelPermission

Examples

Check server and database permissions for servers sql2008 and sqlserver2012.

Get-DbaUserLevelPermission -SqlInstance sql2008, sqlserver2012

Check server and database permissions on server sql2008 for only the TestDB database.

Get-DbaUserLevelPermission -SqlInstance sql2008 -Database TestDB

Check server and database permissions on server sql2008 for only the TestDB database, including public and guest grants, and sys schema objects.

Get-DbaUserLevelPermission -SqlInstance sql2008 -Database TestDB -IncludePublicGuest -IncludeSystemObjects

Author

This command was created by Brandon Abshire. You can find Brandon on his blog.

Get-Help

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

Source Code

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

Related commands