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


Get-DbaRoleMember

Get members of all roles on a SQL instance. Default output includes columns SqlServer, Database, Role, Member.

Screenshots

Examples

To return a custom object displaying SQLServer, Database, Role, Member for all DatabaseRoles.

Get-DbaRoleMember -SqlServer ServerA

To return a gridview displaying SQLServer, Database, Role, Member for all DatabaseRoles.

Get-DbaRoleMember -SqlServer sql2016 | Out-Gridview

To return a gridview displaying SQLServer, Database, Role, Member for both ServerRoles and DatabaseRoles.

Get-DbaRoleMember -SqlServer ServerA\sql987 -IncludeServerLevel

Author

This command was created by Klaas Vandenberghe. You can find Klaas on Twitter and his blog.

Get-Help

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

Source Code

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

Related commands