Get-ACL \\machine_name\folder1 | Format-List *
Run Code Online (Sandbox Code Playgroud)
给我以下包括用户的访问权限(在AccessToString中)
**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
Run Code Online (Sandbox Code Playgroud)
但下面给我空了:
Get-ACL \\machine_name\folder1| Format-List * | select AccessToString
Run Code Online (Sandbox Code Playgroud)
最终,我想获取AccessToString中特定给定用户的条目,例如,只获取"BUILTIN\Administrators"的访问权限.将不胜感激任何帮助.
首先,不应该将任何Format-*cmdlet的输出传递给其他cmdlet.为什么?因为Format-*cmdlet的输出不是您在管道上使用的对象.它们是用于在屏幕上形成信息的专用对象.
如果我们接受命令,Get-Acl c:\ | Format-List * | Get-Member我们将看到这五种.NET类型中有五个对象从Format-List cmdlet传递到Get-Member cmdlet:
这些对象只有格式列表才能很好地显示.此外,Get-Member不会显示任何这些对象具有任何AccessToString属性.
该AccessToString属性只是表示ACL的一小段文本.这不适合过滤,而应该做的是潜入Access属性并过滤其IdentityReference属性上的访问控制条目(ACE).
你会有更好的运气:
Get-Acl c:\ | Select-Object -ExpandProperty Access |
Where-Object identityreference -eq "BUILTIN\Administrators"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7241 次 |
| 最近记录: |