Modifier le registre par GPO

Deploy Registry Items Using the Registry Wizard in GPO

The Registry Wizard in the GPO is the easiest way to make changes to the registry.

  1. Run the Group Policy Management console (gpmc.msc);

  2. Create a new GPO (or edit the existing one), link it to the required container (OU) in AD with the computers (or users) on which you want to apply the registry key, and switch to the policy edit mode;

  3. Expand the GPO section Computer (or UserConfiguration -> Preferences -> Windows Settings -> Registry and select New -> Registry Wizard in the context menu;

    image.png

  4. The Registry Wizard allows you to connect to the registry on a remote computer and select the existing registry key;

  5. Specify the remote computer name you want to connect to;

    image.png

    Note. If the error The network path was not found appears when you try to connect to a computer through the Registry Browser, it most likely this remote computer is turned off, access to it is blocked by a firewall or the Remote Registry service is not started on it.  ****To start the service manually, run these commands on the remote computer: sc config remoteregistry start= demandnet start remoteregistry

     

    image.png

     

  6. Use the Remote Registry Browser to find and select all the registry parameters that you want to deploy through the GPO;

    Note. This registry browser allows you to select only registry keys from the HKEY_LOCAL_MACHINE and HKEY_USERS hives on a remote computer. If you need to set the keys contained in other registry hives, you need to install RSAT on the remote computer. Then run the gpmc.msc console on this computer and use the same procedure to select the registry keys you need.

  7. In this example, I want to import only one registry parameter to the GPP — SearchOrderConfig;

    image.png


  8. The specified registry entry is imported into the GPP console along with the path and current value (0). You can change its value and the desired action (this will be considered later);

    image.png


  9. Thus, you have created a Group Policy to deploy your registry key. The next time the Group Policy settings are updated on the target computers, the value of the SearchOrderConfig registry key will change to 0.

    If the policy doesn’t apply to the client, you can use the GPResult tool for diagnostics.

If this GPO is removed, unlinked from an AD container, or a target computer is moved to another OU, then the value of the registry parameter won`t return to its original (default) value.

How to Manually Create, Edit or Delete a Registry Key using Group Policy?

You can use GPP to create, modify, or delete a specific parameter or registry key by manually specifying the path and value of the registry item.

  1. Select Registry -> New -> Registry Item;

    image.png


  2. Configure your registry item settings:

    Action: Update
    Hive: HKEY_LOCAL_MACHINE
    Key Path: SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DriverSearching
    Value name: SearchOrderConfig
    Value type: REG_DWORD
    Value date: 00000000
    

    image.png


    Do not enter the name of the HIVE in the key path, or an additional subkey will be created in the registry (such as HKEY_HKEY_XXX).

  3. By default, the registry items that are configured by the GPO are set to Update mode.

4 types of actions are available in GPO for registry keys:

image.png

There is a number of other useful options on the Common tab:

image.png

This is how the resulting Group Policy settings will look in the GPMC console (on the Settings tab).

image.png

GPO: Import Registry Data from a REG File

The Registry Group Policy Preference allows an administrator to import a .REG file containing multiple registry entries into Group Policy at once. For this, the REG file must be converted to XML (Group Policy Editor allows you to import files in XML format only).

For example, you have a reference computer on which some settings are configured through the registry. You can export these settings to a REG file by right-clicking on the reg key name in the regedit.exe and selecting Export.

image.png


Save the registry key entries to the REG file.

image.png

If your REG file contains data from different registry hives (HKLM, HKCU, HKEY_CLASSES_ROOT, HKEY_USERS), you need to divide them into separate REG files.

Next, you need to convert this REG file to XML format. You can perform the reg->xml conversation using the online service Reg2GPP https://www.runecasters.com.au/reg2gpp with the PowerShell script RegToXML.ps1.

Copy the resulting XML file in File Explorer and paste it into the Registry section of the Group Policy Editor.

image.png

As a result, all the registry settings from your REG file will appear in the Group Policy console and will be applied to the target domain computers.

image.png

Set Registry Key Permissions with Group Policy

You can use Group Policy to change access permissions (ACL) for specific registry keys. You can use this feature to prevent non-admin users from accessing protected registry keys or to allow regular users the right to modify system keys.

You can configure the registry ACL settings in the GPO section Computer Configuration -> Windows Settings -> Security Settings -> Registry

  1. Select Add key;

  2. Use the built-in Registry Browser to find the registry key you need (or specify the path manually in the following format MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\DriverSearching );

    image.png


  3. Set the new ACL settings for your registry key that you want to apply in the Database Security window. In this example, I want to allow users to make any changes to the system-protected registry key. You need to select the Users group and grant Full Control permission for it. You can enable the inheritance of permissions to the sub-keys by using the Advanced -> Enable inheritance option;

    image.png


    You can add or remove any other security groups, users, and other principals from the local computer or Active Directory.

  4. Save your changes. The new registry key permissions will apply to clients after the GPO is updated.

How to Modify Registry Entries with a GPO Logon Script?

Prior to Windows Server 2008, only logon script BAT files can be used to modify the registry settings by using the GPO. You must use the reg add or reg import commands in such a .bat file to make changes to the registry.

To make changes to the registry using the GPO logon script, you need to create a text file myreg.bat with the necessary commands. For example:

To use the path to the current directory where the BAT script is located, the special %~dp0 parameter is used.

Copy your *.bat (and *.reg if you need to import) to the Netlogon directory on the domain controller ( \\\\woshub.loc\\netlogon).

image.png

Open your GPO and navigate go to Computer Configuration -> Windows Settings -> Scripts -> Startup.

Click Add and specify the UNC path to your bat file in NETLOGON.

image.png

The next time you restart Windows, your BAT file will run and make changes to the registry.

By default, this bat file is run every time you restart your computer. You can configure the GPO to run the script only once.


Revision #1
Created 3 December 2024 12:28:42 by Johann
Updated 3 December 2024 12:37:28 by Johann