2017-08-25 116 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" 
相关问题