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


Find-DbaLoginInGroup

Finds Logins in Active Directory groups that have logins on the SQL Instance. Outputs all the active directory groups members for a server, or limits it to find a specific AD user in the groups.

Screenshots

Examples

To return all active directory groups with logins on Sql Instance DEV01 that contain the AD user Stephen.Bennett.

Find-DbaLoginInGroup -SqlInstance DEV01 -Login ad\Stephen.Bennett

To return all active directory users within all windows AD groups that have logins on the instance.

Find-DbaLoginInGroup -SqlInstance DEV01

To return all active directory users within all windows AD groups that have logins on the instance whose login contains ‘stephen’

Find-DbaLoginInGroup -SqlInstance DEV01 | Where-Object Login -like stephen

Author

This command was created by Stephen Bennett. You can find Stephen blogging at sqlnotesfromtheunderground.wordpress.com.

Get-Help

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

Source Code

Want to see the source code? View Find-DbaLoginInGroup.ps1 on GitHub
 

Related commands