Backup Group Policy Objects through PowerShell

Today one of my tasks was to remove some group policies.
Before I delete those, I always create a backup. Since the list of GPO’s was quite extensive, I turned to PowerShell.
Note that depending on your PowerShell version you may need to import the GroupPolicy module first by running:

Now that’s done, I create a file with all the names of the GPO’s in there. You could type it manually, but I use PowerShell again.
To get the names of all the Group Policy Objects and put that list in the clipboard:

Now paste this list into a textfile and remove the ones you don’t want to create a backup from.

Then we get to the actual task… Backing up the GPO’s:

And as Jaap Brasser pointed out on Twitter, here’s the oneliner to backup all GPO’s without using the text file as input:

Leave a Reply

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