I have take ownership previously using this
$key = 'HKLM:\SOFTWARE\MyKEY'
$acct = New-Object System.Security.Principal.NTAccount("Administrators")
$acl = Get-ACL $key
$acl.SetOwner($acct)
Set-ACL -Path $key -ACLObject $acl
But when I tried to change the Access to READ with this, it creates a new ACL while the original one is still there. How do I alter the original one and how do I do this for all of its subkeys as well ? Can anyone please shed some light ?
$acl = get-acl 'HKLM:\SOFTWARE\MyKEY'
$rule = New-Object System.Security.AccessControl.RegistryAccessRule("Users","FullControl","ContainerInherit,ObjectInherit","None","Allow")
$acl.SetAccessRule($rule)
$acl | Set-Acl -Path 'HKLM:\SOFTWARE\MyKEY'
$acl.AddAccessRule($rule)?