{"id":9830,"date":"2024-06-27T08:05:19","date_gmt":"2024-06-27T08:05:19","guid":{"rendered":"https:\/\/cheapwindowsvps.com\/blog\/how-to-configure-file-and-folder-access-auditing-on-windows-using-group-policy-gpo\/"},"modified":"2025-01-20T09:53:50","modified_gmt":"2025-01-20T09:53:50","slug":"how-to-configure-file-and-folder-access-auditing-on-windows-using-group-policy-gpo","status":"publish","type":"post","link":"https:\/\/cheapwindowsvps.com\/blog\/how-to-configure-file-and-folder-access-auditing-on-windows-using-group-policy-gpo\/","title":{"rendered":"How to Configure File and Folder Access Auditing on Windows Using Group Policy (GPO)"},"content":{"rendered":"<p>The file system audit policy in Windows allows to monitor all access events to specific files and folders on a disk. An administrator can enable the audit policy to identify file and folder creation, read, modification, and deletion events on the NTFS file system. File system auditing is most commonly used to control access and changes to shared network folders on Windows file servers that multiple users can access simultaneously.<\/p>\n<h2>Enable File System Object Access Audit Policy on Windows<\/h2>\n<p>File system object access auditing is not enabled by default in Windows. Access auditing can be enabled via Group Policy. To configure the audit policy on a standalone server, use <a href=\"https:\/\/woshub.com\/group-policy-editor-gpedit-msc-for-windows-10-home\/\" target=\"_blank\" rel=\"nofollow noopener\">the local Group Policy Editor console<\/a> (<code>gpedit.msc<\/code>). If you need to enable the audit policy on multiple computers in an AD domain, use the <a href=\"https:\/\/woshub.com\/group-policy-active-directory\/\" target=\"_blank\" rel=\"nofollow noopener\">domain GPO management console<\/a> (<code>gpmc.msc<\/code>).<\/p>\n<ol>\n<li>Open the GPO editor and go to <strong>Windows Settings -&gt; Security Settings -&gt; Advanced Audit Policy Configuration -&gt; System Audit Policies -&gt; Object Access<\/strong><\/li>\n<li>Open the <strong>Audit File System<\/strong> and specify that only successful access to filesystem objects should be logged (<strong>Configure the following audit events -&gt; Success<\/strong>)<\/li>\n<li>Save the changes and <a href=\"https:\/\/woshub.com\/update-group-policy-settings-windows\/\" target=\"_blank\" rel=\"nofollow noopener\">update local Group Policy settings<\/a> with the command: <code>gpupdate \/force<\/code><\/li>\n<\/ol>\n<p>Or enable the local file system audit policy from the command prompt.<\/p>\n<p>List available audit categories:<\/p>\n<p><code>AuditPol.exe \/list \/subcategory:*<\/code><\/p>\n<div>\n<p>Enable auditing of successful file system object access events:<\/p>\n<p><code>AuditPol.exe \/set \/subcategory:\"File System\" \/success:enable<\/code><\/p>\n<p>Check current audit settings:<\/p>\n<p><code>AuditPol.exe \/get \/category:\"Object Access\"<\/code><\/p>\n<\/div>\n<h2>How to Apply an Audit Policy to a Folder or File in Windows<\/h2>\n<p>Even if a policy is enabled to audit access to files and folders, no actual events are sent to the Event Viewer. Audit settings for the files and folders to be monitored must be manually enabled and configured by the administrator.<\/p>\n<p>For example, your task is to track read\/change\/create events for all files in <em>C:Docs<\/em> folder.<\/p>\n<ol>\n<li>Open the folder properties and go to the <strong>Security<\/strong> -&gt; <strong>Advanced<\/strong> -&gt; <strong>Auditing<\/strong> tab<\/li>\n<li><strong>Click<\/strong> Add and in the <strong>Principal<\/strong> field, select the users and\/or groups whose object access events you want to monitor. Select <strong>Users<\/strong> to audit file access for all users or select <strong>Everyone<\/strong> if you want to include file access events by system process<\/li>\n<li>In Type, specify to track only successful access events (<code>Success<\/code>)<\/li>\n<li>Under <strong>Applies to<\/strong>, you can specify whether the auditing policy should be applied to the folder, files, or subfolders (default value is <em>This folder, subfolders and files<\/em>)<\/li>\n<li>In the <strong>Advanced Permissions<\/strong> list, select only the actions on files and folders that you want to send to the audit log. For example, to monitor only read and file modification events, select the options: <code>List folder\/read data<\/code>, <code>Create files \/ write data<\/code>, <code>Create folders \/ append data<\/code>)<\/li>\n<\/ol>\n<div>See an example of how to use Windows auditing policies to <a href=\"https:\/\/woshub.com\/tracking-files-deletion-using-audit-policy-and-mssql\/\" target=\"_blank\" rel=\"nofollow noopener\">find the user who deleted a file from a shared folder<\/a>.<\/div>\n<ul>\n<li>Save the audit settings.<\/li>\n<\/ul>\n<div>When configuring file system access auditing policies, enable auditing only for the folders and files you need. The <a href=\"https:\/\/woshub.com\/windows-event-viewer-log-size\/\" target=\"_blank\" rel=\"nofollow noopener\">size of the Event Viewer log file<\/a> increases significantly if you have access auditing enabled for a large number of items.<\/div>\n<p>To enable auditing for a specific directory, PowerShell can be used:<\/p>\n<p><code>$Path = \"C:Docs\"<br \/>\n$AuditChangesRules = New-Object System.Security.AccessControl.FileSystemAuditRule('BUILTINUsers', 'Delete,DeleteSubdirectoriesAndFiles', 'none', 'none', 'Success')<br \/>\n$Acl = Get-Acl -Path $Path<br \/>\n$Acl.AddAuditRule($AuditChangesRules)<br \/>\nSet-Acl -Path $Path -AclObject $Acl<\/code><\/p>\n<p>To list the folder audit settings, you can use the following command:<\/p>\n<p><code>(Get-Acl \"C:Docs\" -Audit).Audit<\/code><\/p>\n<p>If you want to recursively scan all directories and identify the subfolders with file system auditing enabled, you can use this script:<\/p>\n<p><code><\/code><\/p>\n<p>$folders=Get-ChildItem &#8220;c:docs&#8221; -Recurse | Where-Object {$_.PSIsContainer}<\/p>\n<p>foreach ($folder in $folders)<\/p>\n<p>{<\/p>\n<p>$auditacl=(Get-Acl $folder.FullName -Audit).Audit<\/p>\n<p>if ($auditacl -ne &#8220;&#8221;) { write-host $folder.FullName }<\/p>\n<p>}<\/p>\n<h2>Viewing File System Access Events on Windows<\/h2>\n<p>The audit policy will write a log to the Event Viewer if any actions are performed on files in the folder with auditing enabled. To view events:<\/p>\n<ol>\n<li>Open the Event Viewer snap-in (<code>eventvwr.msc<\/code>)<\/li>\n<li>Go to the Windows Logs -&gt; Security section and filter the events by source:<\/li>\n<\/ol>\n<p><code>Microsoft Windows security auditing<\/code>, Task Category: <code>File System<\/code><\/p>\n<ul>\n<li>Open any event found. For example, the event with EventID <strong>4663<\/strong> (\u201c<code>An attempt was made to access an object<\/code>\u201c) contains information about the user who interacted with the file:<\/li>\n<\/ul>\n<p><code>Account Name<\/code>:<\/p>\n<p>File name: <code>object_name<\/code>:<\/p>\n<p>type of operation (write to file in this case): Accesses: <code>WriteData (or AddFile)<\/code><\/p>\n<p>However, the Event Viewer console\u2019s filtering and search capabilities are quite poor, and using it to search for all actions on a particular file is inconvenient.<\/p>\n<p>It is better to use PowerShell to find and list all access events for a particular file system object. The following PowerShell script finds and lists all access events for a specified file in Event Viewer (the <a href=\"https:\/\/woshub.com\/search-windows-event-logs-powershell\/\" target=\"_blank\" rel=\"nofollow noopener\">Get-WinEvent cmdlet<\/a> is used to query the Event Viewer):<\/p>\n<pre><\/pre>\n<p>$fileName = &#8220;C:\\docsew_test_file.txt&#8221;<\/p>\n<p>$results = Get-WinEvent -FilterHashtable @{logname=&#8217;Security&#8217;; id=4663,4659} |`<\/p>\n<p>Where-Object { $_.message -match $fileName -and $_.message -notmatch &#8220;Account Name:s*machine$*&#8221;}`<\/p>\n<p>foreach ($result in $results) {<\/p>\n<p>$Account = $result.properties[1].Value<\/p>\n<p>$objectName = $result.properties[6].Value<\/p>\n<p>$accessMask = $result.properties[8].Value<\/p>\n<p>if ( $accessMask -like &#8220;*00000000-*&#8221;) { $accessMask=$result.properties[9].Value}<\/p>\n<p>$accessMask2 = $result.properties[9].Value<\/p>\n<p>$fileOperation = &#8220;&#8221;<\/p>\n<p>switch -Wildcard ($accessMask) {<\/p>\n<p>&#8220;*%%1538*&#8221; { $fileOperation = &#8220;READ_CONTROL&#8221; }<\/p>\n<p>&#8220;*%%4416*&#8221; { $fileOperation = &#8220;ReadData (or ListDirectory)&#8221; }<\/p>\n<p>&#8220;*%%4417*&#8221; { $fileOperation = &#8220;WriteData (or AddFile)&#8221; }<\/p>\n<p>&#8220;*%%4418*&#8221; { $fileOperation = &#8220;AppendData (or AddSubdirectory or CreatePipeInstance)&#8221; }<\/p>\n<p>&#8220;*%%4419*&#8221; { $fileOperation = &#8220;ReadEA&#8221; }<\/p>\n<p>&#8220;*%%4420*&#8221; { $fileOperation = &#8220;WriteEA&#8221; }<\/p>\n<p>&#8220;*%%4423*&#8221; { $fileOperation = &#8220;ReadAttributes&#8221; }<\/p>\n<p>&#8220;*%%4424*&#8221; { $fileOperation = &#8220;WriteAttributes&#8221; }<\/p>\n<p>&#8220;*%%4426*&#8221; { $fileOperation = &#8220;Delete&#8221; }<\/p>\n<p>&#8220;*%%4428*&#8221; { $fileOperation = &#8220;ReadControl&#8221; }<\/p>\n<p>&#8220;*%%4429*&#8221; { $fileOperation = &#8220;WriteDAC&#8221; }<\/p>\n<p>&#8220;*%%4430*&#8221; { $fileOperation = &#8220;WriteOwner&#8221; }<\/p>\n<p>&#8220;*%%4432*&#8221; { $fileOperation = &#8220;Synchronize&#8221; }<\/p>\n<p>&#8220;*%%4433*&#8221; { $fileOperation = &#8220;AccessSystemSecurity&#8221; }<\/p>\n<p>&#8220;*%%4434*&#8221; { $fileOperation = &#8220;MaximumAllowed&#8221; }<\/p>\n<p>&#8220;*%%4436*&#8221; { $fileOperation = &#8220;GenericAll&#8221; }<\/p>\n<p>&#8220;*%%4437*&#8221; { $fileOperation = &#8220;GenericExecute&#8221; }<\/p>\n<p>&#8220;*%%4438*&#8221; { $fileOperation = &#8220;GenericWrite&#8221; }<\/p>\n<p>&#8220;*%%4439*&#8221; { $fileOperation = &#8220;GenericRead&#8221; }<\/p>\n<p>&#8220;*%%1537*&#8221; { $fileOperation = &#8220;DELETE&#8221; }<\/p>\n<p>default { $fileOperation = &#8220;Unknown&#8221; }<\/p>\n<p>}<\/p>\n<p>Write-Host $result.Id $result.TimeCreated $Account $objectName $fileOperation<\/p>\n<p>}<\/p>\n<p>Write-Host $result.Id $result.TimeCreated $Account $objectName $fileOperation<\/p>\n<p>}<\/p>\n<p>You can send the resulting list of access audit events to your log collector, database, <a href=\"https:\/\/woshub.com\/write-output-log-files-powershell\/\" target=\"_blank\" rel=\"nofollow noopener\">text log file<\/a>, or send an email notification using <a href=\"https:\/\/woshub.com\/send-mailmessage-sending-emails-powershell\/\" target=\"_blank\" rel=\"nofollow noopener\">Send-MailMessage<\/a> when a monitored file is accessed\/modified.<\/p>\n<div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>The file system audit policy in Windows allows to monitor all access events to specific files and folders on a disk. An administrator can enable the audit policy to identify file and folder creation, read, modification, and deletion events on the NTFS file system. File system auditing is most commonly used to control access and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9831,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[143,117,100],"tags":[],"class_list":["post-9830","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-group-policies","category-powershell","category-windows-server-2019"],"_links":{"self":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts\/9830","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/comments?post=9830"}],"version-history":[{"count":2,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts\/9830\/revisions"}],"predecessor-version":[{"id":10306,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/posts\/9830\/revisions\/10306"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/media\/9831"}],"wp:attachment":[{"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/media?parent=9830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/categories?post=9830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cheapwindowsvps.com\/blog\/wp-json\/wp\/v2\/tags?post=9830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}