Skip to content

IT-Admins

a website from a systems administrator for systems administrators

    • Home
    • IT-Admins CMDB
      • ITAM – Features
      • ITAM – Release Notes
      • ITAM – Download
      • ITAM – Installation
      • ITAM – Online Manual
        • ITAM – General Functions
        • ITAM – Settings
        • ITAM – Common Modules
          • ITAM – Main Page
          • ITAM – Workstations
          • ITAM – Monitors
          • ITAM – Printers
          • ITAM – Toner-Inventory
          • ITAM – Servers
          • ITAM – Infrastructure Assets
          • ITAM – Other Assets
          • ITAM – Purchases
          • ITAM – Employees
          • ITAM – Software
          • ITAM – Projects and Project Tasks
          • ITAM – Phones/DIDs
          • ITAM – IP Addresses
          • ITAM – Responsibility Matrix
          • ITAM – IT Supplies
        • ITAM – Less Common Modules
          • ITAM – Departments
          • ITAM – Vendors
          • ITAM – Expenses
          • ITAM – Checklist Templates
          • ITAM – LDAP Groups
          • ITAM – Phones and Phone Models
          • ITAM – Links
          • ITAM – Reminders
          • ITAM – Printer Models and Supplies
          • ITAM – VLANs
          • ITAM – Databases
          • ITAM – WebServer
          • ITAM – Certificates
          • ITAM – DNS Entries and Zones
        • ITAM – Research Modules
          • ITAM – TAGs
          • ITAM – Notes
          • ITAM – Checklists
          • ITAM – Incidents
          • ITAM – MAC address search
          • ITAM – LDAP sync Log
          • ITAM – WMI Log
          • ITAM – LDAP compare
          • ITAM – Service Log
    • IT-Admins tool
      • IT-Admins Tool – Features
      • IT-Admins Tool – Scenarios
      • IT-Admins Tool – Screenshots
      • IT-Admins Tool – Release notes
      • FAQ
      • IT-Admins Tool – Download
      • IT-Admins Tool – Online Manual
        • IT-Admins Tool – Overview
        • IT-Admins Tool – Generic search functions
        • IT-Admins Tool – Configuration
        • IT-Admins Tool – Domain Users
        • IT-Admins Tool – Domain Groups
        • IT-Admins Tool – Domain Computers
        • IT-Admins Tool – Domain Contacts
        • IT-Admins Tool – NTFS ACLs
        • IT-Admins Tool – Long Paths
        • IT-Admins Tool – Directory compare
        • IT-Admins Tool – Search function
    • IT Search
      • IT Search – How it works
      • IT Search – Release Notes
      • IT Search – Download
      • IT Search – Installation
      • IT Search – Online Manual
        • Applying updates
        • Search Providers
        • Configuration
        • Error Log viewer
        • Active Users
        • Monitoring and Statistics
        • Backup and Restore
    • EOL Solutions
      • IT Printer Management (EOL)
        • Printer Management EOL – Installation
        • Printer Management EOL – Download
        • Printer Management EOL – Online Manual
          • Printer Management EOL – Executing the script
          • Printer Management EOL – Using the Sys-Search
          • Printer Management EOL – Managing printers
          • Printer Management EOL – Reviewing the log
          • Printer Management EOL – User to printer (v2)
          • Printer Management EOL – Computer to printer (v2)
      • IT Assets Database (EOL)
        • IT Assets DB Video
        • EOL Asset DB – Features
        • EOL Asset DB – Installation
        • EOL Asset DB – Release Notes
        • EOL Asset DB – Update to the newest version
        • EOL Asset DB – Download
        • EOL Asset DB – Online manual
          • EOL Asset DB – Overview
            • EOL Asset DB – The floating / roaming task execution
          • EOL Asset DB – Using the the sys search
          • EOL Asset DB – Main menu
          • EOL Asset DB – Workstations
          • EOL Asset DB – Monitors
          • EOL Asset DB – Departments
          • EOL Asset DB – Printers
            • EOL Asset DB – Printer models and supplies
            • EOL Asset DB – Toner inventory
          • EOL Asset DB – Incidents
          • EOL Asset DB – Software and licenses
          • EOL Asset DB – LDAP change reporting / synchronization
            • EOL Asset DB – Employees
            • EOL Asset DB – LDAP Groups
          • IP addresses – IPAM
          • EOL Asset DB – DNS management
          • EOL Asset DB – Servers and equipment
            • EOL Asset DB – databases
            • EOL Asset DB – backup reviews
            • EOL Asset DB – Certificate management
            • EOL Asset DB – Webserver Management
          • EOL Asset DB – Vendors and contacts
          • EOL Asset DB – Links and URLs
          • EOL Asset DB – Reminders
          • EOL Asset DB – Purchases
          • EOL Asset DB – Expenses
    • Current Page Parent Blog
    • Contact
    • Links

    Find user account lockout events

    There are various ways and tools to tackle this – in the end it boils down to a few facts

    • account lockouts are logged per domain controller – to be more specific – only on the DC where the lockout happened
      • this can be complicated in bigger environments
    • the lockout event 4771 does not necessarily reveal the initial reason – but it should give you enough information about where it occurred to further investigate

    The manual way via Eventlog / Eventviewer in Windows on a DC

    1. right click on the SECURITY eventlog
    2. select Filter Current Log
    3. go to the register card XML
    4. check the box Edit query manually
    5. Insert the XML code below – make sure you replace the USERNAMEHERE value with the actual username
      1. no domain
      2. exact username
      3. NOT case sensitive

    XHTML
    1
    2
    3
    4
    5
    <QueryList>
      <Query Id="0" Path="Security">
        <Select Path="Security">*[System[(EventID=4771)]][EventData[Data[@Name='TargetUserName'] and (Data='USERNAMEHERE')]]</Select>
      </Query>
    </QueryList>

    This results in to a filtered eventlog view for the event id 4771 and the username you specified.

    Using PowerShell to automate this

    PowerShell can execute a script that would give you the same output – I wrote the script below. It expects at least the parameter UserName – see below for more information.

    • UserName 
      • this parameter is mandatory – the exact username without the domain, this is NOT case sensitive
    • DomainController
      • specify this to narrow it down to a single DC – otherwise all domain controllers will be contacted (might take a while)
    • FullDetails
      • set it to $true if you want to see details – otherwise you get only the table format
    • Example
      • Find-AccountLockoutOnDCForUser.ps1 -FullDetails $true -UserName JDoe

    Find-AccountLockoutOnDCForUser.ps1
    PowerShell
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    param(
        [string] $DomainController = "",
        [string] $UserName = "",
        [bool]   $FullDetails = $false
    )
     
    $Query = @"
    <QueryList>
        <Query Id="0" Path="Security">
        <Select Path="Security">*[System[(EventID=4771)]][EventData[Data[@Name='TargetUserName'] and (Data='$UserName')]]</Select>
      </Query>
    </QueryList>
    "@
     
    If ($DomainController.Length -eq 0) {
        Import-Module ActiveDirectory
        $DomainControllers = Get-ADDomainController -Filter * | Select-Object -ExpandProperty Name
        ForEach($DC In $DomainControllers) {
            Write-Host "checking DC: $DC"
            If ($FullDetails) {
                Get-WinEvent -ComputerName $DC -FilterXml $Query -ErrorAction SilentlyContinue | fl
            } Else {
                Get-WinEvent -ComputerName $DC -FilterXml $Query -ErrorAction SilentlyContinue | ft
            }
        }
    } Else {
        If ($FullDetails) {
            Get-WinEvent -ComputerName $DomainController -FilterXml $Query -ErrorAction SilentlyContinue | fl
        } Else {
            Get-WinEvent -ComputerName $DomainController -FilterXml $Query -ErrorAction SilentlyContinue | ft
        }
    }

     

    Tags: accountactive directorydomain controllereventlogfilterlockoutpowershellwindows

    February 20, 2019 by Florian Rossmark scripts security server

    You may also like...

    • Automate Outlook signature roll outs while pulling the information from Active Directory / LDAP

      Automate Outlook signature roll outs while pulling the information from Active Directory / LDAP

    • Reset or Remove the Windows Hello PIN

      Reset or Remove the Windows Hello PIN

    • Office 365 licenses and activated features per user

      Office 365 licenses and activated features per user

    • Next Using PRTG to monitor manufacturing machines
    • Previous Windows Search Index monitoring

    Recent blog posts

    • PRTG sensor to monitor a directory for a specific file type and minimum size and age February 15, 2023
    • APC NetBotz 250 SNMP monitoring with PRTG December 6, 2022
    • Linux and DHCP reservations aren’t working June 28, 2022
    • Check your webpage for mobile friendly readiness June 15, 2022
    • Tools for WebAnalytics and SEO April 21, 2022

    Blog Archives

    Tags

    cleanup database print vmware excel performance ip certificate backup exec dhcp prtg UEFI notification javascript password account html office veritas monitoring web profile SNMP dfs website windows filesystem automate sql lockout backup outlook powershell active directory slack rds security ldap Office 365 script eventlog server gpo network ssl
    • Terms & Conditions
    • Privacy Policy
    • Opt-out preferences
    • SPICEWORKS
    • LOPSA
    • RSS
    • LinkedIn
    • ITML
    • XING

    IT-Admins © 2025. All Rights Reserved.

    Powered by WordPress. Theme by Alx.

      Manage Cookie Consent
      To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
      Functional Always active
      The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
      Preferences
      The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
      Statistics
      The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
      Marketing
      The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
      Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
      View preferences
      {title} {title} {title}