A problem using PowerShell to delete a Registry key with Special Permissions.


hi there,

this problem, i'm trying delete sub registry key has 1 special permission, trying change special permissions fullcontrol same error message, code:

ps c:\windows\system32> $acl=get-acl hkcu:\software\microsoft\windows\currentversion\explorer\fileexts\.lnk\userchoice
ps c:\windows\system32> $permission="administrator", "fullcontrol", "allow"
ps c:\windows\system32> $accessrule=new-object system.security.accesscontrol.registryaccessrule $permission
ps c:\windows\system32> $acl.setaccessrule($accessrule)
ps c:\windows\system32> $acl | set-acl hkcu:\software\microsoft\windows\currentversion\explorer\fileexts\.lnk\userchoice
set-acl : requested registry access not allowed.
@ line:1 char:15
+ $acl | set-acl <<<< hkcu:\software\microsoft\windows\currentversion\explorer\fileexts\.lnk\userchoice
+ categoryinfo : permissiondenied: (hkey_current_us....lnk\userchoice:string) [set-acl], securityexception
+ fullyqualifiederrorid : system.security.securityexception,microsoft.powershell.commands.setaclcommand

could please me?

thanks!

$hkey = 2147483649   $hsubkey = "software\microsoft\windows\currentversion\explorer\fileexts\.lnk\userchoice"  $reg = [wmiclass]"root\default:stdregprov"  $ace = $reg.getsecuritydescriptor($hkey,$hsubkey).descriptor.dacl    $reg.psbase.scope.options.enableprivileges = $true  $sd = ([wmiclass] "win32_securitydescriptor").createinstance()  $sd.controlflags = 0x0004    for($i=0;$i -lt $ace.length;$i++)  {  	if($ace[$i].acetype -ne 1)  	{  		$sd.dacl += $ace[$i]   	}  }  $reg.setsecuritydescriptor($hkey,$hsubkey,$sd)  




Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607