Windows – Extracting GPO through Commandline/Powershell

command-line-interfacegroup-policypowershellwindows

Im writing a script through powershell and i would like to extract the whole local policies. I understand that secedit will exttract the Account policies only, and the only way to do this is via going to the local security policy and right clicking the 'Local Policy' and clicking the Export List. This enables me to get a file where i can work with. Is there any method to do this via the Command-Line?

Best Answer

You can try using LGPO.EXE tool to extract (as well as import) Local Group Policies, e.g.:

To create a GPO backup from local policy:

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

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

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