guide · static export
Security · security

Audit Who Opens a Shared Folder

Object access auditing records every open, write and delete on a folder you choose. Set the policy, put an audit entry on the folder and read event 4663 instead of relying on trust.

by@guidox updated:10/31/26 time:35 min level:Advanced tested on:Windows 11 24H2 works on:Windows 10, Windows 11, Windows Server 2019 tools:Command Prompt as administrator, Event Viewer
TL;DR

Enable **File System** and **File Share** auditing with **auditpol**, add a SACL to the folder with **icacls /audit**, then read **4663** for local access and **5140/5145** for network access.

Before you start

Requirements

  • Admin rights
  • A test folder with a known user
  • Log space on C:
  • 35 minutes
Step by step

Instructions

01

Turn on the audit policy

Auditing is off by default, so event 4663 does not exist yet. Both success and failure matter: success shows **who got in**, failure shows who tried.

auditpol /set /subcategory:"File System" /success:enable /failure:enable
auditpol /set /subcategory:"File Share" /success:enable
auditpol /get /subcategory:"File System"
⚠ warningIf the get output still reads No Auditing, a group policy overwrites the local setting. Check gpresult before going further.
02

Put an audit entry on the folder, not the drive

The SACL decides what gets recorded. Keep it on one folder with inheritance for its children; auditing a whole volume fills the log within minutes.

icacls D:\Share /audit "Everyone:(OI)(CI)(R,W,D)"
icacls D:\Share
tipThe permissions in the audit entry use icacls syntax: R read, W write, D delete. Success and failure follow from the policy set in step 1.
03

Generate one event you can recognise

Open a file in that folder while everything is still quiet. One known access proves the whole chain works before you interpret months of traffic.

Get-Content D:\Share\test.txt -ErrorAction SilentlyContinue
Start-Sleep -Seconds 5
Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4663} -MaxEvents 3 | Select-Object TimeCreated,Message
04

Read the 4663 event properly

The object name is the file, the subject user is who touched it, and the **Access Mask** separates read from write from delete. Pull the fields from the XML instead of the formatted text.

$ev = Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4663} -MaxEvents 20
$ev | ForEach-Object {
  $x = [xml]$_.ToXml()
  [pscustomobject]@{
    Time   = $_.TimeCreated
    User   = ($x.Event.EventData.Data | Where-Object Name -eq 'SubjectUserName').'#text'
    Object = ($x.Event.EventData.Data | Where-Object Name -eq 'ObjectName').'#text'
    Access = ($x.Event.EventData.Data | Where-Object Name -eq 'AccessList').'#text'
  }
}
05

Separate local from network access

A file opened over SMB produces **5140** or **5145** as well as 4663. When time and path line up, the access came from the network rather than from the console.

Get-WinEvent -FilterHashtable @{LogName='Security'; Id=5140,5145} -MaxEvents 10 |
  Select-Object TimeCreated,@{n='Msg';e={($_.Message -split "`n")[0..3] -join ' '}}
06

Size the log before you leave it running

The security log defaults to a few megabytes and overwrites itself. Raise the limit or the evidence is gone exactly when you need it.

wevtutil gl Security
wevtutil sl Security /ms:1073741824
Get-WinEvent -LogName Security -MaxEvents 1 | Select-Object TimeCreated,MachineName
Troubleshooting

Common issues

4663 never appears

Either the policy is not applied — run gpupdate /force and re-check auditpol /get — or the SACL is missing on the parent and not inherited. Add (OI)(CI).

The log fills within minutes

You audit too much. Narrow the SACL to one folder, drop failure auditing for read, and filter the log by object name instead of reading everything.

icacls /audit fails with access denied

Setting a SACL needs SeSecurityPrivilege. Open the prompt elevated and confirm the account is an administrator.

Events exist but the user field is empty

System and kernel access has no interactive user. Correlate with the 4624 logon events for the same logon ID to find the account.

FAQ

Frequently asked

Does auditing slow the share down?

A little, and only for the objects in the SACL. Keep the scope tight and the cost stays negligible.

Can I audit a whole server?

You can, but the log becomes unreadable. Forward events to a collector with a filter instead, or audit only the folders that matter.

How to undo this

Remove the SACL with icacls D:\Share /remove:d Everyone (or delete the audit entry in the Advanced Security dialog) and set the policy back with auditpol /set /subcategory:"File System" /success:disable /failure:disable.

Changelog · 1 entry
  1. 2026-10-31
    First version
Interactive version: checklist, feedback, related guides →

Free · no account needed · tracks your progress