commands

^

Find-DbaLoginInGroup

Author Stephen Bennett, sqlnotesfromtheunderground.wordpress.com , Simone Bizzotto (@niphlod)
Availability Windows, Linux, macOS

 

Want to see the source code for this command? Check out Find-DbaLoginInGroup on GitHub.
Want to see the Bill Of Health for this command? Check out Find-DbaLoginInGroup.

Synopsis

Finds Logins in Active Directory groups that have logins on the SQL Instance.

Description

Outputs all the active directory groups members for a server, or limits it to find a specific AD user in the groups

Syntax

Find-DbaLoginInGroup
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [[-Login] <String[]>]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Find-DbaLoginInGroup -SqlInstance DEV01 -Login "MyDomain\Stephen.Bennett"

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

Example: 2
PS C:\> Find-DbaLoginInGroup -SqlInstance DEV01

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

Example: 3
PS C:\> Find-DbaLoginInGroup -SqlInstance DEV01 | Where-Object Login -like '*stephen*'

Returns all active directory users within all windows AD groups that have logins on the instance whose login contains "stephen"

Required Parameters

-SqlInstance

The target SQL Server instance or instances. This can be a collection and receive pipeline input.

Alias
Required True
Pipeline true (ByValue)
Default Value

Optional Parameters

-SqlCredential

PSCredential object to connect under. If not specified, current Windows login will be used.

Alias
Required False
Pipeline false
Default Value
-Login

Find all AD Groups used on the instance that an individual login is a member of.

Alias
Required False
Pipeline false
Default Value
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message. This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting. Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False