如何运行 HKLM:\Security 的 Get-ACL?

问题描述 投票:0回答:1

Get-Acl 不会提取 HKLM\Security 的 Acl。

此命令适用于所有其他值。当我运行 get-itemproperty "HKLM:\Security" 时,我收到访问被拒绝错误,即使我可以在 regedit.exe 中手动查看注册表项和 ACL。一直以管理员身份运行 ps。

我试过了

get-acl“HKLM:\安全”

结果是空白。尽管为系统和管理员配置了 ACL 规则,但应该已将其拉出。为什么我无法在我拥有正确查看权限的帐户上提取 HKLM\Security 的 ACL?

powershell automation registry acl regedit
1个回答
0
投票

Get-Acl path\goes\here
首先尝试解析
path\goes\here
处的目标项目(相当于
Get-Item path\goes\here
),然后从解析的目标项目中获取关联的 ACL。

HKLM:\SECURITY
上的默认ACL通常配置为拒绝所有人
Read
访问 - 由于拒绝胜过允许,您的管理员访问权限对您没有帮助:-)


解决这个问题的一种方法 - 我确信还有其他可能更安全的方法 - 是使用一些反射来挂钩

RegistryKey.GetAccessControl()
通常在幕后调用的私有构造函数:

# discover private constructor of [RegistrySecurity] class
$registryACLPrivateConstructor = [System.Security.AccessControl.RegistrySecurity].GetConstructors([System.Reflection.BindingFlags]'NonPublic,Instance')[0]

# prepare arguments - hive, path, and section mask
$hiveHandle = (Get-Item HKLM:\).Handle
$keyPath = 'SECURITY'
$sections = [System.Security.AccessControl.AccessControlSections]::All

# construct the ACL by invoking the private ctor
$securityACL = $registryACLPrivateConstructor.Invoke(@($hiveHandle, $keyPath, $sections))

$securityACL
现在包含与
HKLM:\SECURITY

对应的安全描述符对象
© www.soinside.com 2019 - 2024. All rights reserved.