Created
July 29, 2015 04:03
-
-
Save Kevin-Bronsdijk/24933bf7632c84005407 to your computer and use it in GitHub Desktop.
monitoring-failed-sql-server-login-requests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module SQLPS -DisableNameChecking | |
#replace your with your instance name | |
$instanceName = "server\instance"; | |
$srv = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList $instanceName; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$srv.ReadErrorLog() | | |
Where ProcessInfo -like "*Logon*" | | |
Where Text -like "*Login failed for*" | | |
Format-List |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$srv.ReadErrorLog() | | |
Where { ($_.LogDate.Date -eq (Get-Date).Date) -and ($_.ProcessInfo -like "*Logon*") -and ($_.Text -like "*Login failed for*")} | | |
Group Text | Where { ($_.Count -gt 5)}|Sort count -Descending | Format-Table Count, Name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment