registry permissions question

Discussion in 'Windows 10' started by RanCorX2, Jan 3, 2018.

  1. RanCorX2

    RanCorX2 MDL Addicted

    Jul 19, 2009
    894
    462
    30
    does anyone know how or if it's possible to change permissions on some keys in subtree but exclude a couple?
    when each key has a different name?

    example;

    hkey_local_machine\software\blahh\

    key1blip
    key2blop
    key3boo
    key4blag
    key5blee

    change permissions on key 1 & 2 but ignore / exclude 3,4 & 5

    can this be done somehow?
     
  2. GodHand

    GodHand MDL Senior Member

    Jul 15, 2016
    400
    444
    10
    Get-ChildItem is your friend.

    If your keys contain wildcards, you need to use a wildcard comparison operator like "-like" and "-notlike" instead of "-in" or "-notin"

    Use an array for the keys and use the Where-Object (?) cmdlet. This is not a working script, since I do not know the keys you need, but it's generally how I mass-remove keys based on criteria.

    Code:
    $path="\SOFTWARE\Microsoft\Windows\blahh\"
    [string[]]$subkeyArgs = @("key1", "key2", etc)
    Get-ChildItem HKLM:$path -Recurse -EA Stop | Get-ItemProperty -Name LocalPackage -EA SilentlyContinue | ? { $_.LocalPackage -in "*" + $subkeyArgs } | Set-ItemProperty -Name etc...