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


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