Local Group Policy Object Utility (Windows EXE)

What

LGPO.exe is Microsoft’s Local Group Policy Object utility. It lets administrators import, export, and apply local Windows Group Policy settings from the command line. This can be useful when deploying security baselines or local policy settings to Windows devices that are not managed through Active Directory Group Policy.

When/Why

LGPO.exe can help apply required local policy settings to Windows devices so they meet your organization’s security and compliance requirements.

Features:

Before you begin

Example: Deploy LGPO.exe with FileWave

  1. Download LGPO.zip.
  2. Add the required policy files to the same Fileset, such as:
    • registry.pol
    • GptTmpl.inf
    • Audit.csv
    • lgpo.txt
  3. Create a Windows script in the Fileset.
  4. Use the LGPO command that matches the policy file you are deploying, for example:
    LGPO.exe /m "%~dp0registry.pol" /v
    gpupdate /force
  5. Associate the Fileset with a test device first.
  6. After validation, deploy to the intended device group.

LGPO Policy Example Template

Example Template Fileset:

Use the template variable examples below to apply or remove one Windows local policy value.

You only need to set a few environment variables:

Example Fileset Contents

Example contents: LGPO.exeapply_policy.ps1, and remove_policy.ps1GeneratedPolicy.txt is created by the script at runtime.

ExampleLGPOTemplate.png

Required Variables

FW_POLICY_TYPE and FW_POLICY_DATA are required when applying a policy. They are not required when removing a policy.

Variable Example Notes
FW_POLICY_KEY Software\Policies\Microsoft\Windows\Installer Registry policy path. You may also use a full HKLM:\... path.
FW_POLICY_VALUE DisableMSI Registry value name.
FW_POLICY_TYPE DWORD Required for apply. Common values: DWORDSZQWORDEXPAND_SZMULTI_SZ.
FW_POLICY_DATA 2 Required for apply.

Optional Variables

For User policies, include LGPO.exe and use LGPO text import. Direct registry fallback is intended for Computer policies because FileWave often runs scripts as LocalSystem.

Variable Default Notes
FW_POLICY_SCOPE Computer Use Computer for HKLM policy or User for HKCU policy.
FW_LGPO_EXE .\LGPO.exe Custom path to LGPO.exe.
FW_LGPO_TEXT_PATH .\GeneratedPolicy.txt Where the generated LGPO text file is written.
FW_RUN_GPUPDATE true Runs gpupdate.exe /force.
FW_DIRECT_REGISTRY_FALLBACK true Directly writes simple Computer policies if enabled.

Example: Disable Windows Installer

$env:FW_POLICY_KEY = "Software\Policies\Microsoft\Windows\Installer"
$env:FW_POLICY_VALUE = "DisableMSI"
$env:FW_POLICY_TYPE = "DWORD"
$env:FW_POLICY_DATA = "2"

.\apply_policy.ps1
To remove the same policy:

$env:FW_POLICY_KEY = "Software\Policies\Microsoft\Windows\Installer"
$env:FW_POLICY_VALUE = "DisableMSI"

.\remove_policy.ps1
How

The attached zip contains LGPO.exe, Microsoft’s Local Group Policy Object utility: LGPO.zip

LGPO.exe has four modes:

  1. Import and apply policy settings;
  2. Export local policy to a GPO backup;
  3. Parse a registry.pol file to "LGPO text" format;
  4. Build a registry.pol file from "LGPO text".

To apply policy settings, use one or more of the following LGPO.exe options. Each option can be repeated as needed:

/g path                             import settings from one or more GPO backups under "path"
/m path\registry.pol     import settings from registry.pol into machine config
/u path\registry.pol      import settings from registry.pol into user config
/s path\GptTmpl.inf     apply security template
/a[c] path\Audit.csv     apply advanced auditing settings; /ac to clear policy first
/t path\lgpo.txt              apply registry commands from LGPO text

/e <name>|<guid>       enable GP extension for local policy processing; specify a GUID, or one of these names:
              **  "zone" for IE zone mapping extension
              **  "mitigation" for mitigation options, including font blocking
              **   "audit" for advanced audit policy configuration
              
/boot                                reboot after applying policies
/v                                       verbose output
/q                                       quiet output (no headers)

To create a GPO backup from local policy:

LGPO.exe /b path [/n GPO-name]

/b path                       Create GPO backup in "path"
/n GPO-name           Optional GPO display name (use quotes if it contains spaces)

To parse a Registry.pol file to LGPO text (stdout):

LGPO.exe /parse [/q] {/m|/u} path\registry.pol

/m path\registry.pol         parse registry.pol as machine config commands
/u path\registry.pol          parse registry.pol as user config commands
/q                                           quiet output (no headers)

To build a Registry.pol file from LGPO text:

LGPO.exe /r path\lgpo.txt /w path\registry.pol [/v]

/r path\lgpo.txt              Read input from LGPO text file
/w path\registry.pol     Write new registry.pol file

Validate the policy

After deployment, you can validate the result on the Windows device using one or more of the following:

gpupdate /force
gpresult /h C:\Temp\gpresult.html /f

You can also review the relevant local policy settings using the Local Group Policy Editor, where applicable.

Troubleshooting

Digging Deeper


Revision #11
Created 2023-11-20 21:12:38 UTC by Andrew Kloosterhuis
Updated 2026-05-15 13:43:48 UTC by Andrew Kloosterhuis