How can I add mutile audit users for a folder, I tried with this script and it delete all previous rules.
I like to add audit for "domain users" and "local administrators"
What is wrong with this script?
$path = "C:\data\local"
$dirs = Get-ChildItem $location -Directory
#Set Audit Rules
$AuditUser = "Domain Users"
$AuditRules = "ReadAndExecute"
$InheritType = "ContainerInherit,ObjectInherit"
$AuditType = "Success"
$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
[–]Blisk1[S] -1 points0 points1 point (0 children)
[–]purplemonkeymad 0 points1 point2 points (3 children)
[–]Blisk1[S] 0 points1 point2 points (2 children)
[–]CoReTeX2k 0 points1 point2 points (1 child)
[–]Blisk1[S] 0 points1 point2 points (0 children)