2017-08-25 95 views
0
Get-ACL \\machine_name\folder1 | Format-List * 

給我的下面,包括對用戶的訪問權限(在AccessToString)PowerShell的:獲取ACL,並獲得遠程文件夾對特定用戶權限

**AccessToString   : NT AUTHORITY\Authenticated Users Allow AppendData 
          NT AUTHORITY\Authenticated Users Allow -536805376 
          NT AUTHORITY\SYSTEM Allow FullControl 
          BUILTIN\Administrators Allow FullControl 
          BUILTIN\Users Allow ReadAndExecute, Synchronize** 
AuditToString   : 
AccessRightType   : System.Security.AccessControl.FileSystemRights 
AccessRuleType   : System.Security.AccessControl.FileSystemAccessRule 
AuditRuleType   : System.Security.AccessControl.FileSystemAuditRule 
AreAccessRulesProtected : True 
AreAuditRulesProtected : False 
AreAccessRulesCanonical : True 
AreAuditRulesCanonical : True 

但低於給我空:

Get-ACL \\machine_name\folder1| Format-List * | select AccessToString 

最終,我想獲取AccessToString中特定給定用戶的條目,例如爲什麼只能獲得「BUILTIN \ Administrators」的訪問權限 將不勝感激

+1

刪除'|格式列表*' –

+0

僅提供部分數據: -------------- 「NT AUTHORITY \ Authenticated Users Allow AppendData ...」另外 - 如何獲取特定用戶的權限? –

+2

'Get-ACL。 | Select -Expand AccessToString' –

回答

4

首先,不應該將任何Format- * cmdlet的輸出傳輸到其他cmdlet中,原因何在?因爲Format- * cmdlet不是你在流水線上使用的對象,它們是專門用於在屏幕上形成信息的對象。

如果我們採用命令Get-Acl c:\ | Format-List * | Get-Member,我們將看到這五個.NET類型中有五個對象它們從Format-List cmdlet傳遞到Get-Member cmdlet:

  • Microsoft.PowerShell.Commands.Internal.Format.FormatStartData
  • Microsoft.PowerShell.Commands.Internal.Format.GroupStartData
  • Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData
  • Microsoft.PowerShell.Commands.Internal .Format.GroupEndData
  • Microsoft.PowerShell.Commands.Internal.Format.FormatEndData

這些對象只存在於格式列表很好地顯示。此外Get-Member不顯示任何這些對象具有任何AccessToString屬性。

AccessToString屬性只是表示ACL的文本的一個塊。這不適合過濾,而應該做的是深入探索Access屬性並篩選其IdentityReference屬性上的訪問控制項(ACE)。

您將有更好的運氣與此:

Get-Acl c:\ | Select-Object -ExpandProperty Access | 
    Where-Object identityreference -eq "BUILTIN\Administrators" 
相關問題