1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
$ListRegistryKey= Get-Content -path C:\Chemin\du\fichier\texte\
foreach ($line in $ListRegistryKey)
{
Set-Variable -name Path -Value $line
$AuditUser = "Everyone"
$AuditRule = "FullControl"
$InheritType = "ContainerInherit", "ObjectInherit"
$AuditType = "Failure"
$AccessRule = New-Object System.Security.AccessControl.RegistryAuditRule($AuditUser,$AuditRule,$InheritType,"None",$AuditType)
$ACL = New-Object System.Security.AccessControl.RegistrySecurity
$ACL.SetAuditRule($AccessRule)
Set-Acl registry::$path -AclObject $ACL
$AuditRule = "CreateSubKey", "Delete","SetValue","WriteKey","TakeOwnership","ChangePermissions"
$AuditType = "Success"
$AccessRule = New-Object System.Security.AccessControl.RegistryAuditRule($AuditUser,$AuditRule,$InheritType,"None",$AuditType)
$ACL.AddAuditRule($AccessRule)
Set-Acl registry::$path -AclObject $ACL
} |