Powershell Script to find a SQL\Windows login in SQL Server

  • Comments posted to this topic are about the item Powershell Script to find a SQL\Windows login in SQL Server

    Vishnu Gupthan
    PowershellAcademy
    www.powershellacademy.com

  • Well, this probably works. 
    But if you have SSMS 2016 (16.3+) installed you can just use the Get-SqlLogin cmdlet.
    Download here today! sqlps.io/dl

    foreach ($RegisteredSQLs IN dir -recurse 'SQLSERVER:\SQLRegistration\Database Engine Server Group\' |
    WHERE {$_.Mode -ne 'd'} )
    {
    Get-SqlLogin -ServerInstance $RegisteredSQLs.Name -LoginName BobbyTables
    }

    Granted, if the login doesn't exist you'll need to wrap a Try/Catch around it to get nice, pretty output, but it works.

    @SQLvariantI have a PowerShell script[/url] for you.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply