This PowerShell snippet sets the owner using the Set-Acl command:
$ACL = Get-Acl -Path "Folder1""Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion"
$User = New-Object System.Security.Principal.Ntaccount("TestUser1")
$ACL.SetOwner($User)
$ACL | Set-Acl -Path "Folder1""Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion"
Get-ACL -Path "Folder1""Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion"
You need to run this code as administrator.
Source : How to Use PowerShell to Manage Folder Permissions.