Hi,
Hope you can help. I’ve created this script to remove all auditing from all files/folder/sub-folders. It seems to work apart from where inheritance has been disabled. What am I doing wrong please?
$PathList = Get-Content C:\NetApp\script\pathlist.txt
foreach($path in $PathList)
{
$acl = Get-Acl $path -Audit
$acl.SetAuditRuleProtection($True, $False)
$acl.GetAuditRules($True, $False, [System.Security.Principal.SecurityIdentifier]) | Foreach-Object { $acl.RemoveAuditRule($_); }
Set-Acl $path $acl
$files = Get-ChildItem -Path $Path -File -Recurse
foreach ($file in $files) {
$fileacl = Get-Acl $file.FullName -Audit
$fileacl.SetAuditRuleProtection($True, $False)
$fileacl.GetAuditRules($True, $False, [System.Security.Principal.SecurityIdentifier]) | Foreach-Object { $fileacl.RemoveAuditRule($_); }
Set-Acl $file.FullName $fileacl
}
}```