Question : Script to enable folder auditing

Hi all

I am looking for a script that will enable the windows folder auditing for a particular folder. I need to set success auditing for the Everyone Group.

 I have tried using the setacl.exe but everytime I run a command I get a error "Invalid Parameter". I tried using the command SetACL.exe -on "test.txt.txt" -ot file -actn list -lst "f:tab;w:o but it keeps erroring out.

I am trying to us this powershell script but I cannot get it to work because it keeps asking me for a Typename. i am not sure what to enter for the type name

$ACL = new-object System.Security.AccessControl.DirectorySecurity
$AccessRule = new-object
System.Security.AccessControl.FileSystemAuditRule("everyone","Modify","ContainerInherit,
ObjectInherit", "None","success")
$ACL.SetAuditRule($AccessRule)
$ACL | Set-Acl "C:\New Folder"


I am open to using any language of script. We can not use Group policies because the PC's are at VPN sites.

Answer : Script to enable folder auditing


Like this then :)

Chris
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
$ACL = Get-Acl "C:\New Folder"

$AuditRule = New-Object Security.AccessControl.FileSystemAuditRule("everyone","Modify","ContainerInherit, ObjectInherit", "None", "success")
$ACL.AddAuditRule($AuditRule)

# Rule for Delete SubFolders and Files
$AuditRule = New-Object Security.AccessControl.FileSystemAuditRule("everyone","Delete","ContainerInherit, ObjectInherit", "InheritOnly", "success")
$ACL.AddAuditRule($AuditRule)

$ACL | Set-Acl "C:\New Folder"
Random Solutions  
 
programming4us programming4us