title: Is there any way to set only Auditing permissions using "Set-ACL" function in Powershell script?
body: <p>I have been looking for setting an ACL only for the Auditing permissions, We can able to retrieve only auditing permissions using &quot;-Audit&quot; Parameter in &quot;Get-ACL&quot; function, but there is no option of set only the Auditing permissions in &quot;Set-ACL&quot;  , lack of &quot;-Audit&quot; parameter in that . Even if we use the Generic &quot;Set-ACL $Path&quot; command , it wipes out the DACL permissions and sets Auditing permission that we retrieved from &quot;Get-ACL -Audit $Path&quot;.This causes deletion of DACL , I have attached references and generic code here , let me know if there is any option to set SACL without affecting DACL using &quot;Set-ACL&quot; or any other functions in Powershell script.Thanks in Advance.</p>
  <p>References : <a href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/get-acl?view=powershell-7.1" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/get-acl?view=powershell-7.1</a>
  <a href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-acl?view=powershell-7.1" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-acl?view=powershell-7.1</a></p>
  <p>code :</p>
  <pre><code>Function Add-SACL {
  [cmdletbinding()]
  Param (
      [string]$Path,
      [PSObject]$folderAcl
  ) 
  
  $permission1 = &quot;everyone&quot;,&quot;ChangePermissions,TakeOwnership&quot;,&quot;ContainerInherit&quot;,&quot;None&quot;,&quot;Success,Failure&quot;
  $AuditRule1 = New-Object  System.Security.AccessControl.FileSystemAuditRule $permission1
  $folderAcl.AddAuditRule($AuditRule1)
  
  $permission2 = &quot;everyone&quot;,&quot;CreateFiles,WriteData,CreateDirectories,AppendData,WriteAttributes,WriteExtendedAttributes,DeleteSubdirectoriesAndFiles,Delete&quot;,&quot;ContainerInherit,ObjectInherit&quot;,&quot;None&quot;,&quot;Success,Failure&quot;
  $AuditRule2 = New-Object  System.Security.AccessControl.FileSystemAuditRule $permission2
  $folderAcl.AddAuditRule($AuditRule2)
  
  
  $folderAcl.SetAuditRuleProtection($false,$false)
  $folderAcl | Set-Acl $Path
      
  }
  
  $parentSACL = Get-ACL -Audit $parentfolder | select Path,Audit,AreAuditRulesProtected
  Add-SACL -Path $parentfolder
  </code></pre>