how do you change the auditing settings of a specific folder with CMD?

Nowtside 1 Reputation point
2022-03-14T09:41:34.807+00:00

I am basically trying to repeat the following manual steps but with a CMD command : Properties>Advanced>Auditing>Add> Everyone, Full control.
I only want to turn on auditing for one specific folder and it needs to be done with CMD due to hardening reasons.

Windows for business | Windows Client for IT Pros | Directory services | Active Directory
Windows for business | Windows Client for IT Pros | Devices and deployment | Configure application groups
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Limitless Technology 39,926 Reputation points
    2022-03-17T08:36:06.727+00:00

    Hello @Nowtside

    You can use the command line Auditpol in order to manipulate the audit settings to folders and subsequent items:

    Auditpol
    https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/cc731451(v=ws.11)?redirectedfrom=MSDN

    Hope this helps with your query,

    ---------
    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments

  2. MotoX80 36,401 Reputation points
    2022-03-17T12:55:18.257+00:00

    You can do it with Powershell.

    # Refer to https://www.reddit.com/r/PowerShell/comments/pukqlx/setup_audit_folder/
    $path = "C:\temp\test"
    $AuditUser = "Everyone"
    $AuditRules = "ReadAndExecute"
    $InheritType = "ContainerInherit,ObjectInherit"
    $AuditType = "Fail"
    $AccessRule = New-Object System.Security.AccessControl.FileSystemAuditRule($AuditUser,$AuditRules,$InheritType,"None",$AuditType)
    $ACL = (get-item $path).GetAccessControl('Access')
    $ACL.SetAuditRuleProtection($false, $false)
    $ACL.AddAuditRule($AccessRule)
    $ACL | Set-Acl $path
    

    I saw in your other post that Powershell was disabled in your environment. IMHO, that is a huge mistake and is only going to cause your organization trouble in the future as Microsoft migrates more and more OS support tasks/functionality into Powershell.

    Setacl appears to be able to also do it, but if your org has PS disabled, I doubt that they will allow freeware on your system.

    https://helgeklein.com/setacl/documentation/command-line-version-setacl-exe/

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.