Script to implement advanced registry key permissions?

0

Is it possible to add advanced registry key permissions via a script?

ie:

HKLM\SYSTEM\CurrentControlSet\Services\SharedAccess\Defaults\FirewallPolicy

MpsSvc – Query Value, Set Value, Create SubKey, Enumerate SubKeys, Notify, Delete, Read Control

John Scott

Posted 2016-05-12T05:04:14.003

Reputation: 1

Get-Acl -Path HKLM:\SYSTEM\CurrentControlSet\Services\SharedAccess\Defaults\FirewallPolicy| select -exp access | Where-Object {$_.IdentityReference -eq "NT SERVICE\MpsSvc"}| Format-List seems to be pretty clear; however, Set-Alc would be more complicated. – JosefZ – 2016-05-12T07:43:08.397

Answers

0

You can use a Powershell script, some examples:

Listing all subkeys:

PS> Get-ChildItem -Path hkcu:\


   Hive: Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER

SKC  VC Name                           Property
---  -- ----                           --------
  2   0 AppEvents                      {}
  7  33 Console                        {ColorTable00, ColorTable01, ColorTab...
 25   1 Control Panel                  {Opened}
  0   5 Environment                    {APR_ICONV_PATH, INCLUDE, LIB, TEMP...}
  1   7 Identities                     {Last Username, Last User ...
  4   0 Keyboard Layout                {}
...

Create a key (2 ways):

PS> New-Item -Path hkcu:\software\_DeleteMe
PS> New-Item -Path Registry::HKCU\_DeleteMe

Delete a key:

PS> Remove-Item -Path hkcu:\Software\_DeleteMe
PS> Remove-Item -Path 'hkcu:\key with spaces in the name'

Jeff Bencteux

Posted 2016-05-12T05:04:14.003

Reputation: 148