|
@ -10,11 +10,24 @@ function Import-Registry($reg) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function Takeown-Registry($key) { |
|
|
function Takeown-Registry($key) { |
|
|
# TODO works only for LocalMachine for now |
|
|
# TODO does not work for all root keys yet |
|
|
|
|
|
switch ($key.split('\')[0]) { |
|
|
|
|
|
"HKEY_CLASSES_ROOT" { |
|
|
|
|
|
$reg = [Microsoft.Win32.Registry]::ClassesRoot |
|
|
|
|
|
$key = $key.substring(18) |
|
|
|
|
|
} |
|
|
|
|
|
"HKEY_CURRENT_USER" { |
|
|
|
|
|
$reg = [Microsoft.Win32.Registry]::CurrentUser |
|
|
|
|
|
$key = $key.substring(18) |
|
|
|
|
|
} |
|
|
|
|
|
"HKEY_LOCAL_MACHINE" { |
|
|
|
|
|
$reg = [Microsoft.Win32.Registry]::LocalMachine |
|
|
$key = $key.substring(19) |
|
|
$key = $key.substring(19) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
# set owner |
|
|
# set owner |
|
|
$key = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows Defender\Spynet", "ReadWriteSubTree", "TakeOwnership") |
|
|
$key = $reg.OpenSubKey($key, "ReadWriteSubTree", "TakeOwnership") |
|
|
$owner = [Security.Principal.NTAccount]"Administrators" |
|
|
$owner = [Security.Principal.NTAccount]"Administrators" |
|
|
$acl = $key.GetAccessControl() |
|
|
$acl = $key.GetAccessControl() |
|
|
$acl.SetOwner($owner) |
|
|
$acl.SetOwner($owner) |
|
|