如何使用powershell中注册表项上的getauditrules()获取acl对象中的审核规则?
我正在尝试将审核规则应用于此代码如何使用powershell中注册表项上的getauditrules()获取acl对象中的审核规则?,powershell,acl,audit,Powershell,Acl,Audit,我正在尝试将审核规则应用于此代码 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:\softwa
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()方法:
在??位置,我尝试了NTaccount对象和windowsSecurity。它不会返回错误,事实上也不会返回任何东西。这真是令人失望,因为在使用windows界面时,我可以看到应用了审核规则。
我不明白什么类型的对象需要getauditrules()方法。
有人能帮我吗?尝试将
-audit
参数添加到get-acl
cmdlet(此检索SACL
,系统访问控制列表
)
您可以使用:
$acl.getauditrules($true,$true, [System.Security.Principal.NTAccount] )
或
根据您的目标。尝试将
-audit
参数添加到get-acl
cmdlet(此检索SACL
,系统访问控制列表
)
您可以使用:
$acl.getauditrules($true,$true, [System.Security.Principal.NTAccount] )
或
基于您的目标。请原谅,有没有办法通过调用.NET方法而不是powershell cmdlet来产生结果?我以前对powershell cmdlet进行过大量测试,尤其是I/O cmdlet(文件和注册表)的测试速度要慢得多。我知道1ms vs 3ms看起来不多,但当您想要映射整个注册表时,肯定会注意到它。请原谅,有没有办法通过调用.NET方法而不是powershell cmdlet来生成结果?我以前对powershell cmdlet进行过大量测试,尤其是I/O cmdlet(文件和注册表)的测试速度要慢得多。我知道1ms和3ms看起来不多,但是当你想要映射整个注册表时,它肯定会被注意到。
$acl.getauditrules($true,$true, [System.Security.Principal.NTAccount] )
$acl.getauditrules($true,$true, [System.Security.Principal.SecurityIdentifier] )