(How to set permissions on registry, even when you dont have access)
In this video I demonstrate 2 scenario's for setting registry permissions with powershell, the first scenario is a very simple one, the second example is about a user who lost access to the registry key and we need to restore the permissions and ownership.
Make sure you download setacl.exe (64 bits) and place it in the c:\Windows\system32 folder.
*powershell
*learn powershell
*automation
*learn automation
*windows
*windows powershell
*automatic installations
*set registry permissions with powershell
*take ownership of registry keys
*change permissions on registry with powershell
Code:
Simple script
$subkey = "SOFTWARE\mark\wrong"
$good = get-acl "HKLM:\SOFTWARE\mark\good"
$pathwrong = "HKLM:\$subkey"
$newacl = get-acl -Path $pathwrong
$newacl.SetSecurityDescriptorSddlForm($good.Sddl)
set-acl -path $pathwrong -AclObject $newacl
Script when no access (you need to downloads setacl.exe!)
$subkey = "SOFTWARE\mark\wrong"
$owner = "Administrators"
SetACL.exe -on "HKEY_LOCAL_MACHINE\$subkey" -ot reg -actn setowner -ownr "n:$owner" -rec Yes
SetACL.exe -on "HKEY_LOCAL_MACHINE\$subkey" -ot reg -actn ace -ace "n:$owner;p:full" -rec Yes
$good = get-acl "HKLM:\SOFTWARE\mark\good"
$pathwrong = "HKLM:\SOFTWARE\mark\wrong\"
$newacl = get-acl -Path $pathwrong
#here we need to check the owner
$newacl.SetSecurityDescriptorSddlForm($good.Sddl)
set-acl -path $pathwrong -AclObject $newacl
14 окт 2024