Windows Enumeration: How Defenders Detect and Limit It
Defensive guide to Windows enumeration: events 4798, 5145, 4688, 4104, Sysmon, remote SAM limits, SMBv1, LAPS, Defender for Identity. No attack steps.
Windows enumeration is the reconnaissance step where an account lists users, groups, shares, hosts and processes to learn how a network is laid out. Defenders detect it through process creation, account-management, file-share and PowerShell logs, and limit it by restricting remote SAM queries, removing SMBv1, requiring SMB signing, rotating local admin passwords and trimming share permissions.
This guide is written for the blue side: system administrators, SOC analysts and DevSecOps engineers who need to know what enumeration looks like in their logs and which settings reduce what a low-privilege account can learn. It contains no attack commands. If you are also studying how attackers work, our Linux counterpart, Linux privilege escalation: risks, hardening and detection, takes the same defensive approach.
Key takeaways
- Enumeration is normal-looking activity. The same events appear when an administrator opens a management console, so detection depends on a baseline of who, from where and with which process.
- Four log sources cover most of it: process creation with command line (event 4688 or Sysmon event 1), account enumeration (event 4798), network share access (event 5145) and PowerShell script block logging (event 4104).
- Command-line logging in event 4688 is off by default. It must be enabled by Group Policy, and the logs it produces can contain sensitive arguments, so protect who can read them.
- The setting "Network access: Restrict clients allowed to make remote calls to SAM" limits who can enumerate local accounts and groups over the network. Test it in audit-only mode first.
- Removing SMBv1, requiring SMB signing, using Windows LAPS and tightening share permissions shrink the data an ordinary account can read.
- Microsoft Defender for Identity has a dedicated category for reconnaissance and discovery alerts, which complements raw event logs.
What enumeration means to a defender
After an attacker or a malicious insider gets a foothold on a Windows host or a domain account, they usually ask the same questions. Who are the users and administrators? Which machines exist? What shares are open? What is running here? The answers come from legitimate Windows interfaces: account databases, directory queries, file-sharing protocols and the process list. That is why enumeration is hard to block outright and easier to detect than to prevent.
Two ideas guide the defense. First, reduce the answers a low-privilege account can get, so enumeration returns less. Second, record enough telemetry that unusual enumeration stands out from the background noise of administration.
Where enumeration shows up in telemetry
| What is being listed | Evidence to collect | Control that reduces exposure |
|---|---|---|
| Local group membership of an account | Event 4798 (Audit User Account Management), generated when a process enumerates a user's security-enabled local groups | Restrict remote SAM calls; keep admin group membership small |
| Users and groups over the network (SAMR) | System log events 16962 to 16969 from Directory-Service-SAM when the restriction policy is defined | Network access: Restrict clients allowed to make remote calls to SAM |
| File shares and files | Event 5145 (Audit Detailed File Share), source address, share name and relative target name | Least-privilege share permissions; SMB signing; no SMBv1 |
| Processes launched on a host | Event 4688 with command line, or Sysmon event 1 with parent process and hashes | Application control; limit interactive logons on servers |
| PowerShell activity | Event 4104 script block logging | Script block logging and Protected Event Logging; constrained administration |
| Directory queries and discovery across the domain | Microsoft Defender for Identity reconnaissance and discovery alerts | Tiered administration; remove stale privileged accounts |
| Network connections and DNS lookups | Sysmon event 3 (network connection) and event 22 (DNS query) | Segmentation; host firewall rules between workstations |
Turn on the logging that makes enumeration visible
Process creation with command line
Event 4688 records every new process, but only if the Audit Process Creation subcategory (Advanced Audit Policy, Detailed Tracking) is enabled. To include the command line, enable the Administrative Template setting "Include command line in process creation events" under System, Audit Process Creation. Microsoft documents that this setting is not configured by default, and warns that anyone who can read the Security log will then see the command line arguments of successfully created processes. Command lines can hold passwords or personal data, so restrict log access and forward the events to a central store.
If you use Advanced Audit Policy, set "Audit: Force audit policy subcategory settings" to Enabled so that legacy basic audit settings do not override your subcategories. Event 4719 is logged when the audit policy is changed, which helps you notice the override.
Account and group enumeration
Event 4798, "A user's local group membership was enumerated", is generated under the Audit User Account Management subcategory on Windows 10 and Windows Server 2016 and later. It names the account that asked, the account whose groups were listed and the process that made the request. Microsoft's own monitoring guidance for this event is practical:
- Watch for any enumeration whose subject is a high-value account that should rarely do this.
- Alert when the process name is not in a standard folder such as System32 or Program Files.
- Compare the process name against a list you expect, for example the management console itself.
A harmless way to see this event in a lab is to open a management console as an administrator and then read the Security log. Microsoft's own example of the event shows mmc.exe as the caller, which is a reminder of how ordinary the activity can be.
Get-WinEvent -FilterHashtable @{ LogName = 'Security'; Id = 4798; StartTime = (Get-Date).AddHours(-1) } |
Select-Object TimeCreated, Message
File share access
Event 5145 is generated each time a network share object is checked for access, under the Audit Detailed File Share subcategory. It carries the account, the source IP address, the share name and the file or folder name. Microsoft warns that failure events appear only when access is denied at the share level, not when NTFS denies it. This event can be very noisy on file servers, so enable it where you have a plan to analyze it: sensitive shares, domain controllers and jump hosts. Microsoft's guidance is to monitor for source addresses outside your internal ranges and for accounts reaching files they are not expected to use.
PowerShell
PowerShell script block logging records the content of script blocks that PowerShell processes, as event 4104. For Windows PowerShell 5.1 the events are in the Microsoft-Windows-PowerShell/Operational log, and for PowerShell 7 in PowerShellCore/Operational. You enable it through Group Policy ("Turn on PowerShell Script Block Logging"). Microsoft recommends Protected Event Logging alongside it, because logged scripts can capture credentials, and a compromised host's logs could otherwise help an attacker extend their reach. Protected Event Logging encrypts the content with a public key and keeps the private key on a secure collector.
Sysmon for process, network and DNS detail
Sysmon is a Windows service and driver from Sysinternals that writes detailed events to Applications and Services Logs, Microsoft, Windows, Sysmon, Operational. It logs process creation with full command line and parent process, hashes of executables, and, if you configure it, network connections (event 3) and DNS queries (event 22). Microsoft states that Sysmon does not analyze the events it creates, so you need a SIEM or hunting process to do that. Install with a configuration file:
sysmon64 -accepteula -i c:\windows\config.xml
Start from a maintained community configuration and tune it for your environment. Process access (event 10) and image load (event 7) are high volume, so filter them before you turn them on widely.
Limit what a low-privilege account can learn
Restrict remote calls to the SAM database
The policy "Network access: Restrict clients allowed to make remote calls to SAM" controls which users can enumerate users and groups in the local SAM database and Active Directory over the network. Microsoft describes the risk this way: a low-privileged user can use the SAM remote protocol to list accounts, including privileged ones, which gives an attacker a map for later steps.
The defaults matter:
- Windows 10 version 1607 and later, and Windows Server 2016 and later, ship with a restrictive default on non-domain-controllers. The default descriptor
O:SYG:SYD:(A;;RC;;;BA)allows only the local Administrators group to read. - On domain controllers running Windows Server 2016 or later, Everyone has read permission to keep compatibility.
- Earlier versions perform no access check by default, even after the hotfix is installed.
Deploy it carefully. Admin tools, scripts and software that enumerate users remotely can break, and Microsoft notes that the policy could affect offline address book generation on Exchange 2013 and 2016 servers. Use audit-only mode first, which logs what would have been denied without blocking it:
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Lsa" -Name RestrictRemoteSamAuditOnlyMode -Type DWord -Value 1
Then review System log events 16962 to 16969 from the Directory-Service-SAM source. Event 16968 shows a client that would have been denied in audit mode, with its SID and network address. Event 16965 records a real denial, and by default it is logged once per 15-minute throttling window, with the rest counted in event 16969. Add legitimate callers to the SDDL string, then switch off audit-only mode. Restarts are not required.
Retire SMBv1 and require signing
SMBv1 has significant security vulnerabilities, and Microsoft strongly encourages not using it. It is not installed by default on Windows 11 or Windows Server 2019 and later. Check and disable it, and optionally audit who still uses it:
Get-SmbServerConfiguration | Select-Object EnableSMB1Protocol, AuditSmb1Access
Set-SmbServerConfiguration -AuditSmb1Access $true
Set-SmbServerConfiguration -EnableSMB1Protocol $false
With auditing on, each SMBv1 connection attempt creates an event with ID 3000 in the Microsoft-Windows-SMBServer\Audit log, which tells you what to fix before you switch it off. SMB signing is required by default in Windows 11, version 24H2 and Windows Server 2025. Microsoft advises fixing the remote server or replacing the device instead of turning signing off.
Windows LAPS for local administrator passwords
When many machines share one local administrator password, learning it on one machine opens the rest. Windows LAPS rotates each device's local administrator password and backs it up to Active Directory or Microsoft Entra ID. It is available at no cost on supported Windows 11, Windows 10 devices that still receive updates, and Windows Server 2019 and later with the April 11, 2023 update or newer. It has its own event log channel and a PowerShell module.
Share permissions and administrative tiers
- Remove broad groups such as Everyone and Authenticated Users from shares that do not need them, and grant access to named groups.
- Keep domain admin accounts off ordinary workstations and member servers, so enumeration of a workstation never reveals a privileged logged-on account.
- Delete stale accounts and empty privileged groups so there is less to find.
Detection ideas worth building
| Signal | Why it matters | How to tune |
|---|---|---|
| Event 4798 where the process is outside System32 or Program Files | Matches Microsoft's own monitoring recommendation | Allow-list your management tools by full path |
| One account or source IP touching many hosts' shares in a short window (event 5145) | Fan-out across hosts is unusual for most users | Exclude backup, patch and inventory servers by IP |
| Event 4798 with a high-value account as subject | Privileged accounts should do this rarely and from known hosts | Keep a list of administrators and their jump hosts |
| New denials (16965 or 16968) after the SAM policy is defined | Shows something is querying accounts remotely that is not on the allow list | Review the first week, then alert on new client SIDs |
| Built-in admin utilities launched with command lines by non-admin users (event 4688 or Sysmon 1) | The tools are legitimate, so the user and parent process give the signal | Baseline per role: IT staff versus finance versus developers |
| Script block events (4104) containing directory or share listing logic on non-admin hosts | Scripts can enumerate with built-in modules | Review by host group and account type |
The point of the table is correlation. A single 4798 is nothing. A 4798 from an unexpected process, then 5145 events from the same logon ID across several servers, deserves a ticket. Microsoft suggests correlating by Logon ID with event 4624 and by process ID with event 4688. See also our posts on log aggregation by pipeline layer and alerting tools for ways to centralize and alert on these events.
Microsoft Defender for Identity
If you run Active Directory, Microsoft Defender for Identity adds sensors on domain controllers and raises alerts grouped by attack phase. Microsoft lists reconnaissance and discovery as one of the alert categories, alongside persistence and privilege escalation, credential access and lateral movement. Microsoft also notes that Defender for Identity is not designed as an auditing or logging solution that records every operation, so it supplements, not replaces, the Windows audit policies above. Tuning is format-specific, so follow the exclusion method for the alert format you see.
When you see suspicious enumeration
- Identify the account, the host and the process from the event. Use the Logon ID to find the matching sign-in event and see how the account logged on.
- Decide whether it is expected: an administrator, a scheduled inventory job or a management console are all common explanations.
- If it is not, contain the host with your endpoint tool, reset the account's credentials and revoke active sessions.
- Look for follow-on activity: new logons to other hosts, new services, group changes and sign-ins from unusual locations. Enumeration is usually a step on the way to something else.
- Feed what you learned back into the allow-list and the alert rules.
A hardening checklist you can work through
| Area | Action | Done when |
|---|---|---|
| Auditing | Enable Audit Process Creation and command line capture; Audit User Account Management; Audit Detailed File Share on chosen servers | Events 4688, 4798 and 5145 reach your SIEM |
| PowerShell | Enable script block logging and Protected Event Logging | Event 4104 is collected and encrypted at rest |
| Endpoint | Deploy Sysmon with a tuned configuration | Event 1, 3 and 22 volume is understood and filtered |
| SAM | Run audit-only mode, then enforce the restriction policy | No unexplained 16968 events remain |
| SMB | Disable SMBv1, keep SMB signing on | No event 3000 hits in the SMB audit log |
| Local admin | Deploy Windows LAPS | No two machines share a local admin password |
| Shares | Replace Everyone with named groups | Share permission review is documented |
| Identity | Review privileged groups; deploy Defender for Identity if you run AD | Reconnaissance alerts reach the on-call analyst |
If you are building these skills as part of a security career, hands-on practice in a lab domain is the quickest route. The DevSecOps course in Pune (Kharadi classroom or live online) covers security automation and monitoring, and the ELK stack course covers centralizing and searching logs. Also see zero trust security tools for DevOps teams.
Frequently asked questions
What is Windows enumeration?
It is the reconnaissance step in which an account lists users, groups, computers, shares, services and processes to understand a Windows environment. Administrators do this for legitimate reasons too, so context decides whether it is suspicious.
Which Windows event IDs show enumeration?
Useful ones are 4798 for local group membership enumeration, 5145 for network share object access, 4688 for process creation (with command line if enabled), 4104 for PowerShell script blocks, and System events 16962 to 16969 for remote SAM restrictions.
Is event 4688 command-line logging on by default?
No. You must enable Audit Process Creation and the Group Policy setting to include the command line in process creation events. Microsoft documents it as not configured by default.
How do I stop users from enumerating accounts remotely?
Configure "Network access: Restrict clients allowed to make remote calls to SAM" so that only approved groups can read. Run it in audit-only mode first and review events 16968 before enforcing.
Does disabling SMBv1 help against enumeration?
It removes an old protocol with known weaknesses from your estate. Enable SMBv1 auditing first, find any clients that still use it, and fix them before you disable it.
Can Sysmon replace Windows Security auditing?
No. Sysmon adds detail such as hashes, parent processes, network connections and DNS queries, but Microsoft notes it does not analyze events. Run it together with Windows auditing and a SIEM.
Where should I practice this safely?
In an isolated lab domain that you own. Generate normal administrative activity, read the resulting events, then tune your policies. Do not test on production or on systems you do not own.
Official references
- Microsoft Learn: Event 4798, a user's local group membership was enumerated
- Microsoft Learn: Event 5145, a network share object was checked
- Microsoft Learn: Command line process auditing
- Microsoft Learn: Restrict clients allowed to make remote calls to SAM
- Microsoft Learn: about_Logging_Windows
- Microsoft Learn: Detect, enable and disable SMBv1, SMBv2 and SMBv3
- Microsoft Learn: Windows LAPS overview
- Microsoft Learn: Sysmon
- Microsoft Learn: Microsoft Defender for Identity security alerts
What's Your Reaction?
Like
0
Dislike
0
Love
0
Funny
0
Angry
0
Sad
0
Wow
0