簡體   English   中英

如何使用powershell中的注冊表項上的getauditrules()獲取acl對象中的審計規則?

[英]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(此檢索SACLSystem 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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM