using powershell to set file audit settings

Welcome Forums General PowerShell Q&A using powershell to set file audit settings

This topic contains 2 replies, has 2 voices, and was last updated by

3 months, 2 weeks ago.

  • Author
  • #128715

    Points: 14
    Rank: Member

    from my understanding, I can use set-acl to add file/folder audit setting

    can I somehow feed that command a text file that contains a list of file names that need the exact same audit settings?

    For every new computer we set up, I need to change audit settings on 75-100 files with the exact same settings. We do this manually but would really like to script it.

    The only code I found online is the following but it just copies the audit settings from one folder to another:

    get-acl c:\users\administrator\desktop\test2\ -Audit| set-acl c:\users\administrator\desktop\test\

  • #128723

    Points: 41
    Rank: Member

    A simple loop should do it. Using a an existing ACL is easier than building one, which can be a bit fiddly.

    $files = Get-Content c:\temp\fileList.txt
    $acl = Get-ACL c:\myAuditTemplate\ -Audit
    foreach ($file in $files) {
      Set-Acl -path $file -AclObject $acl
    • #128732

      Points: 14
      Rank: Member


      I'll test that out and see if I run into any issues.

The topic ‘using powershell to set file audit settings’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort