Active Directory: Export and import a group policies


powershell has some command lets to deal with with group policies. The command lets can be found in the GroupPolicy module.

Exporting a group policy can be done by Backup-GPO

PS D:\> mkdir D:\GPOs
PS D:\> Backup-GPO  -Name Domain-Defender-Config -Path D:\GPOs
DisplayName     : Domain-Defender-Config
GpoId           : 6128de44-a812-9018-5342-aa2318888d71
Id              : 178233e1-1111-54cf-b34e-f3c60cb959ba
BackupDirectory : D:\GPOs
CreationTime    : 01.01.2020 04:00:55
DomainName      :
Comment         :

To import the backup of the group policy use Import-GPO. Backup ID is the folder name. The target GPO must already exists or, if you have the permissions, you can set the -CreateIfNeeded parameter.

PS D:\> dir D:\GPOs
Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-----       30.11.2021     21:51                {178233e1-1111-54cf-b34e-f3c60cb959ba}
PS D:\> Import-GPO -BackupId '{178233e1-1111-54cf-b34e-f3c60cb959ba}' -Path D:\GPOs -TargetName My-Defender-Config


Advertisment to support

Leave a Reply

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

Time limit is exhausted. Please reload CAPTCHA.