Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/vim/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell 正在检索安全描述符并获取FileSystemRights的编号_Powershell_Acl - Fatal编程技术网

Powershell 正在检索安全描述符并获取FileSystemRights的编号

Powershell 正在检索安全描述符并获取FileSystemRights的编号,powershell,acl,Powershell,Acl,使用Get Acl我正在尝试获取文件夹的访问权限。问题是,对于某些组,我得到的是一个数字,而不是访问类型。示例如下: get-acl "C:\TestFolder" | % {$_.access} FileSystemRights : -536805376 AccessControlType : Allow IdentityReference : TestDomain\Support IsInherited : False InheritanceFlags : ObjectInh

使用
Get Acl
我正在尝试获取文件夹的访问权限。问题是,对于某些组,我得到的是一个数字,而不是访问类型。示例如下:

get-acl "C:\TestFolder" | % {$_.access}
FileSystemRights  : -536805376
AccessControlType : Allow
IdentityReference : TestDomain\Support
IsInherited       : False
InheritanceFlags  : ObjectInherit
PropagationFlags  : InheritOnly

有没有办法把这个号码翻译回它的名字?

快速而肮脏的翻译:

268435456-完全控制

-536805376-修改、同步

-1610612736-读取和执行,同步

如果你想了解翻译过程,这是我目前能找到的最好的方法:
FileSystemRights属性的值是一个无符号32位整数,其中每一位表示一个特定的访问权限。除“通用”权限(位28-31)和访问SACL的权限(位23)外,大多数权限都列在中。更多详细信息,请参阅

如果要将ACE访问掩码分解为其特定的访问权限(vulgo“扩展权限”),可以执行以下操作:

$accessMask=[已订购]@{
[uint32]'0x8000000'='GenericRead'
[uint32]'0x40000000'='GenericWrite'
[uint32]'0x20000000'='GenericExecute'
[uint32]'0x10000000'='GenericAll'
[uint32]'0x02000000'='MaximumAllowed'
[uint32]'0x01000000'=“AccessSystemSecurity”
[uint32]'0x00100000'=“同步”
[uint32]'0x00080000'='WriteOwner'
[uint32]'0x00040000'='WriteDAC'
[uint32]'0x00020000'='ReadControl'
[uint32]'0x00010000'=“删除”
[uint32]'0x00000100'='WriteAttributes'
[uint32]'0x00000080'='ReadAttributes'
[uint32]'0x00000040'='DeleteChild'
[uint32]'0x00000020'=“执行/遍历”
[uint32]'0x00000010'=“WriteExtendedAttributes”
[uint32]'0x00000008'='ReadExtendedAttributes'
[uint32]'0x00000004'='AppendData/AddSubdirectory'
[uint32]'0x00000002'='WriteData/AddFile'
[uint32]'0x00000001'='ReadData/ListDirectory'
}
$fileSystemRights=Get Acl-LiteralPath'C:\some\folder\u或\u file'|
选择对象-展开访问|
选择对象-展开文件系统权限-第一个1
$permissions=$accessMask.Keys|
其中,对象{$fileSystemRights.value\uu-band$}|
ForEach对象{$accessMask[$\U]}
简单权限
FullControl
Modify
ReadAndExecute
等只是这些扩展权限的特定组合<例如,code>ReadAndExecute是以下扩展权限的组合:

  • ReadData/ListDirectory
  • 执行/遍历
  • ReadAttributes
  • ReadExtendedAttributes
  • ReadControl
因此,
ReadAndExecute
的访问掩码的值为131241

如果希望结果是简单权限和其余扩展权限的组合,可以执行以下操作:

$accessMask=[已订购]@{
...
}
$simplePermissions=[已订购]@{
[uint32]'0x1f01ff'=“完全控制”
[uint32]'0x0301bf'=“修改”
[uint32]'0x0200a9'=“读取和执行”
[uint32]'0x02019f'=“读写”
[uint32]'0x020089'=“已读”
[uint32]'0x000116'=“写入”
}
$fileSystemRights=Get Acl-LiteralPath'C:\some\folder\u或\u file'|
选择对象-展开访问|
选择对象-展开文件系统权限-第一个1
$fsr=$fileSystemRights.value__
$permissions=@()
#获得简单权限
$permissions+=$simplePermissions.Keys | ForEach对象{
中频($fsr-频带$)-eq$){
$simplePermissions[$\uUx]
$fsr=$fsr-波段(-bnot$\uU4)
}
}
#获取剩余的扩展权限
$permissions+=$accessMask.Keys|
其中对象{$fsr-band$}|
ForEach对象{$accessMask[$\U]}

答案很好,尽管在
$fsr=$fsr-band(-bNOT$\ux)
中有输入错误。注意:二进制
-bNOT
而不是逻辑
-not
@JosefZ感谢您的提醒。固定的。