Listing failed login attempts

This recipe lists failed login attempts in your SQL Server instance.

Getting ready

In order to get some entries in this recipe, you will need to simulate some failed login attempts in your SQL Server instance, if you don't already have any previous failed logins. One way to do this is to try logging in to SQL Server using SQL Server Management Studio and providing an incorrect username or password.

How to do it...

To check the failed login attempts, follow these steps:

  1. Open PowerShell ISE as an administrator.
  2. Import the SQLPS module and create a new SMO Server Object as follows:
    #import SQL Server module Import-Module SQLPS -DisableNameChecking #replace this with your instance name $instanceName = "localhost" $server = New-Object ...

Get SQL Server 2014 with PowerShell v5 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.