2014-11-21 146 views

回答

2

查看PowerShell Access Control module。 3.0版在PowerShell中幾乎完全實現,與使用Get-Acl相比,它非常慢,但我認爲它可以做你要求的(並且我正在處理速度問題)。

它有一個名爲Get-EffectiveAccess的函數,它可以計算一個委託人對安全對象的有效訪問權限,但我不認爲這就是你要找的。這聽起來像你想要得到一個提供讀/寫'首字母'屬性的ACE的列表。爲此,您可以使用Get-AccessControlEntry:

# Get any ACEs that grant or deny read or write access to the 'initials' property: 
Get-ADUser TestUser | Get-AccessControlEntry -ObjectAceType initials 

# Get any ACEs that grant or deny write access to the 'initials' property: 
Get-ADUser TestUser | Get-AccessControlEntry -ObjectAceType initials -ActiveDirectoryRights WriteProperty 

# Get any ACEs that grant write access to the 'initials' property: 
Get-ADUser TestUser | Get-AccessControlEntry -ObjectAceType initials -ActiveDirectoryRights WriteProperty -AceType AccessAllowed 

這些示例都使用Get-ADUser來查找單個用戶。無論您使用AD模塊還是DirectorySearcher,您都應該能夠爲任何AD對象提供該功能。您甚至可以將專有名稱作爲-Path參數提供給函數。

-ObjectAceType參數應該能夠接受一個GUID,或者您可以放入一個或多個屬性/屬性集合/驗證的寫入/擴展權限/類對象名稱(您可以使用*作爲通配符)。

如果你確實想計算實際有效訪問,這裏是GET-EffectiveAccess功能的一些例子:

# Get effective access that 'AnotherUser' has over 'TestUser' object (this doesn't include property, property set, validated write, etc effective permissions): 
Get-ADUser TestUser | Get-EffectiveAccess -Principal AnotherUser 

# Same as before, but this time include effective access down to the ObjectAceType level: 
Get-ADUser TestUser | Get-EffectiveAccess -Principal AnotherUser -ObjectAceTypes initials 
Get-ADUser TestUser | Get-EffectiveAccess -Principal AnotherUser -ObjectAceTypes init* 

,而在過去的幾個例子的工作,我注意到,有一些錯誤是當使用Get-EffectiveAccess和-ObjectAceTypes參數編寫時,即使函數看起來工作正常。如果我有周末的時間,我可以解決這個問題,但我可能只是等待4.0版本。

+0

感謝Rohn, Get-AccessControlEntry完美地工作。當我運行Get-EffectiveAccess時出現了一些錯誤,但是我從Get-AccessControlEntry獲得了我需要的報告。 再次感謝! Majid – 2014-11-25 22:01:38

相關問題