Group Policy Preferences allow you to deploy Registry settings. If you have to deploy a large number of complicated Registry settings, you must convert a REG file into an XML file, which you can then import into Group Policy Preferences.

Michael Pietroforte

Michael Pietroforte is the founder and editor in chief of 4sysops. He has more than 35 years of experience in IT management and system administration.

The Windows Registry editor allows you to export a Registry key into a REG file. Unfortunately, you can’t just import the REG file into Group Policy Preferences; the Group Policy Editor only accepts XML files. Fortunately, Malcolm McCaffery wrote a PowerShell script that converts REG to XML.

Export REG file ^

To export a Registry key, launch the Registry editor (type regedit on the Start Screen), right-click the key, and then select Export from the context menu. The Registry editor will then prompt you to specify a file name for your REG file.

Export Registry key to REG file

Export Registry key to REG file

Convert REG to XML ^

Malcolm’s PowerShell script to convert REG to XML contains a little bug that prevents the script from accepting input parameters. The author probably uploaded a version he used for testing. I modified the script, so you can use it right away. You can download the modified script here. If you just launch RegToXML.ps1, it will ask for the name of the REG and XML files. You can specify the input parameters like this:

If the conversion is successful, you should see the XML output in the PowerShell console.

RegToXML supports the common Registry types:

  • REG_DWORD
  • REG_QWORD
  • REG_EXPAND_SZ
  • REG_MULTI_SZ
  • REG_BINARY
  • REG_SZ

Import into Group Policy Preferences ^

Importing the converted Registry path into Group Policy Preferences is simple, too, although not self-evident. You have to right-click the XML file in File Explorer and then copy it to the Windows clipboard.

Copy XML file to clipboard

Copy XML file to clipboard

Now, in the Group Policy Editor, navigate to User Configuration (or Computer Configuration) > Preferences > Windows Settings > Registry and right-click the white pane on the right. In the context menu, select Paste.

Import Registry key into Group Policy Preferences

Import Registry key into Group Policy Preferences

The Group Policy Editor will insist that you confirm the import.

Confirm import

Confirm import

If the Group Policy Editor doesn’t like your XML file, you will get an error message.

The pasted document is invalid and will be ignored

The pasted document is invalid and will be ignored.

I know it is hard to be ignored. The only thing you can do now is try it again. Perhaps you just copied the wrong file. It is also possible that something went wrong during the REG to XML conversion.

You can also first create a folder and then paste the XML file. Right-click the Registry symbol, navigate to New, and then select Collection Item.

Collection Item

Collection Item

If the Group Policy Editor considers you worthy enough not to be ignored, after you paste the XML file you will see your Registry key with the complete folder structure of the Registry hive. You can then navigate to the keys to see whether the values are okay.

Imported Registry key

Imported Registry key

Notice that this method of deploying Registry settings with Group Policy Preferences is only something for absolute Registry geeks. The Registry settings can vary on different machine types with different configurations. Thus, you really have to understand what you are doing here.

If you are a Windows Taskbar expert, you have probably already noticed what Registry key I imported here. The Taskband key contains all the settings for the apps that you pinned to the Taskbar. However, deploying these Registry settings with Group Policy is not enough to configure the Taskbar properly. In one of my next posts, I will cover this topic in more detail.

Are you an IT pro? Apply for membership!

0
Share
44 Comments
  1. Robert 1 year ago

    Hi,

    I converted a .reg file to .xml without any errors. But when I try to import it into the GPE I get "the pasted document is invalid and will be ignored" is there any way to find out what is invalid in the document?

    Can anyone post a link to the xml format that the GPE can read? I cant find it anywhere.

    Thanks!

    0

    • Author

      You can follow the example in this post and then compare the XML file with yours. You might also want to check your XML file. The fact that there was no error message doesn't ensure that everything worked.

      0

  2. Robert 1 year ago

    Ah! I got it working now! The xml file was located on a network share, looks like the GPE doesn't like that. Once I moved the file to a local drive it imported without a problem.
    The error message could have shown a bit more info about what went wrong though! "computer says no" doesn't really help.

    Hope this helps others.

    Thanks!

    0

  3. Mark Mancini 1 year ago

    I get a LONG list of this

    You cannot call a method on a null-valued expression.
    At C:\regtoxml.ps1:188 char:21
    + $xml.WriteattributeString("name",$valueName)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\regtoxml.ps1:189 char:21
    + $xml.WriteattributeString("default",$default)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\regtoxml.ps1:190 char:21
    + $xml.WriteattributeString("type","REG_SZ")
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\regtoxml.ps1:191 char:21
    + $xml.WriteattributeString("displayDecimal","0")
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\regtoxml.ps1:192 char:21
    + $xml.WriteAttributeString("value",$value)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\regtoxml.ps1:193 char:21
    + $xml.WriteEndElement()
    + ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    You cannot call a method on a null-valued expression.
    At C:\regtoxml.ps1:194 char:21
    + $xml.WriteEndElement()

    0

  4. Robert 1 year ago

    Hi Mark,

    if remember correctly, that is because you need to specify the full path to both input and output file.

    regards,

    robert

    0

  5. seth gregory 1 year ago

    Do you know how to include the "apply once and do not reapply" setting on each key in the XML file?

    0

  6. andrea cappini 6 months ago

    HI to all,

    I'm looking for a tool that do exactly the opposite: convert GPO to .reg file. In my environment are some clients with windows 10  home so I want that pcs acts like others in domain (with w10 pro).

     

    0

  7. Luc Fullenwarth 6 months ago

    @Andrea

    I don't know if such a tools exist, but here in a Microsoft official Excel sheet, you have the full list of GPO/Registry matches:

    https://www.microsoft.com/en-us/download/details.aspx?id=57464

    0

  8. andrea cappini 6 months ago

    Hello,

    I need exactly the opposite. Convert GPO settings in an importable .reg file. This because I have domain clients and non domain clients, so I want client not in domain acts like others.

    Manually create a .reg is very difficult because my GPOs do many changes, so identify what registry keys are modified in a domain client is not simple.

    Do you know if exists a utility for this? That would be great.

    Thank you

    0

  9. andrea cappini 6 months ago

    Thank you Luc, I'll try

    0

Leave a reply

Your email address will not be published. Required fields are marked *

*

© 4sysops 2006 - 2019

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account