[英]Powershell command to find registry key advanced audit settings (permissions)
[英]how to get audit rule in acl object with getauditrules() on registry key in powershell?
我正在尝试使用此代码应用审核规则
function add-acl($Right,$Access)
{
$audit = "mydomain\myaccount","$Right","containerinherit","none","$Access"
$r = new-object system.security.accesscontrol.registryauditrule $audit
$acl.addauditrule($r)
}
$acl = get-acl hklm:\software\_test
add-acl "CreateSubKey" "Success"
add-acl "Delete" "Success"
add-acl "Delete" "Failure"
$acl | set-acl
但是此代码在不考虑早期规则的情况下编写审计规则。 所以我想在应用代码之前检索审计规则。 为此,我使用了getauditrules()方法:
$acl.getauditrules($true,$true,??)
在??? 位置,我试过NTaccount对象和windowsSecurity。 它不会返回错误,实际上根本不返回任何内容。 这实在令人失望,因为在使用Windows界面时,我可以看到应用了审计规则。 我不明白什么类型的对象期望getauditrules()方法。 有人能帮我吗 ?
尝试将-audit
参数添加到get-acl
cmdlet(此检索SACL
, System Access Control List
)。
$acl = get-acl hklm:\software\_test -audit
你可以使用:
$acl.getauditrules($true,$true, [System.Security.Principal.NTAccount] )
要么
$acl.getauditrules($true,$true, [System.Security.Principal.SecurityIdentifier] )
根据你的目标。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.