I am trying to create a startup script that can be distributed via GPO to laptops (running 64bit Windows 7 Professional) to make it impossible for any user (including local administrators) to display the passwords for connected wireless networks. I have this done mostly but cannot figure out how to remove Users/Groups from the security entries on the key.
This is what I have so far, it basically defines variables and changes the ownership of the key to the local "Administrators" group.
$hkey = "HKEY_CLASSES_ROOT\AppID\{86F80216-5DD6-4F43-953B-35EF40A35AEE}"
$exe = "\\server\share\SetACL.exe"
& $exe -on $hkey -ot reg -actn setowner -ownr n:'Administrators'
The end result of the script should remove "BUILTIN\Administrators", "BUILTIN\Users", "SERVICE\TrustedInstaller" from Security entries, leaving only "BUILTIN\SYSTEM" with read permissions, and then taking permission away from SYSTEM and giving them to BUILTIN\Administrators. This configuration has been tested and works.
In order to use get-acl you have to map a ps-drive to the hkcr hive (because it's an alias that points to both {hklm,hkcu}\SOFTWARE\Classes?) so I have this for that, if get-acl is even needed to remove permissions:
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT
$dkey = "HKCR:\AppID\{86F80216-5DD6-4F43-953B-35EF40A35AEE}"
$acl = get-acl $dkey
I have found so much on the internet about adding deny permissions but I do not want to add deny, I just want to remove the entries as if clicking "remove" through properties>security.
Thanks!