Backup All GPOs Powershell

This script is to Backup all GPOs and save it to a server, in a folder named as the current date. You can use this script running in a schedule task for weekly GPO Backups.  

 
 
 
 
 
3.7 Star
(9)
5,618 times
Add to favorites
Group Policy
2/18/2013
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Getting error while running this script : The library, drive, or media pool is empty. (Exception from HRESULT: 0x800710D2) . However its backing up few policies not all.
    2 Posts | Last post September 04, 2018
    • Getting error while running this script : 
      The library, drive, or media pool is empty. (Exception from HRESULT: 0x800710D2) . However its backing up few policies not all.
      Please help
    • Activate GPMC Logging via registry and check log files:
      
      HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Diagnostics
      
      GpMgmtTraceLevel (REG_DWORD) 
      
      Set it to 2 to log all 
      or just 1 to log errors only
      
      LogFile location:
      %temp%\GpMgmt.log
  • Script not backing up ALL GPOs
    2 Posts | Last post November 14, 2017
    • Hello,
         I have been testing this in our forests and domains and I am finding that the GPO-Backup does not seem to backup ALL GPOs.  In one of our forests we have over 2000 GPOs and we have been using a wscript to back them up.  Problem is it takes days to complete....
      
      When I run this it runs, finishes and when I check folder that was created it only has perhaps 150 or so of the 2000+ GPOs.  I tried on a domain that has less than 200 GPOs and get the same result...only about 150 get backed up.
      
      I've even opened powershell ISE ran the script...checked after it finished and saw the limited number of GPOs...then typed:  
      
      Backup-Gpo -All -Path E:\GPOBACKUPS\[DomainFolder]\$date -domain [DomainName]
      
      Same Result.
      
      1.  Is there a limitation on the number of GPOs that the cmdlet will backup?
      2.  Could a temporary connection issue cause this (thought I would think it would throw an error which it does not).
      
      I originally used this as a basis for a longer script to backup multiple domains.  It ran, created the folders, backed up some GPOs but again, in each case it was limited to about 150.  There are no space issues on the server to which I am saving the GPOs.
      
      Any suggestions would be helpful.
      
      William
    • Maybe your task user doesn´t have access on some GPOs?
      I used this script for 2600+ GPOs
  • Include output or results??
    1 Posts | Last post May 07, 2015
    • Tim,
      
      Thanks for this script.  One thing I would like to add is an e-mail notification that includes some type of output or results determining whether the script ran successfully, either as an attachment or as part of the e-mail body.  I know how to script the e-mail notification but cannot find any type of event log or other results of the backup.  Any recommendations?
      
      Thanks,
      Dave
  • Clean up old folders from previous backups
    2 Posts | Last post May 04, 2015
    • When this script is scheduled I see it creates a dated folder in the chosen directory.
      
      Do people run another script to delete the older folders.  what's a good mechanism to keep say 3 copies and delete older ones.
      
      Thanks
      
      JohnA UK
    • Check this script:
      https://gallery.technet.microsoft.com/scriptcenter/Delete-files-older-than-x-13b29c09
      
  • failing with Object reference not set to an instance of an object error
    2 Posts | Last post May 04, 2015
    • Hi,
      
      After taking 99 GPOs it is failing with the below error. Any Idea on why it is failing ?
      
      Backup-GPO : Object reference not set to an instance of an object.
      At C:\Users\GPOBackupS.PS1:9 char:11
      + Backup-Gpo <<<<  -All -Path E:\BackupGPOsAll\$date
          + CategoryInfo          : NotSpecified: (:) [Backup-GPO], NullReferenceException
          + FullyQualifiedErrorId : System.NullReferenceException,Microsoft.GroupPolicy.Commands.BackupGpoCommand
      
      
      
    • I used the script to backup over 1000 policies.
      Check this article
      https://support.microsoft.com/en-us/kb/2379592/
      
      FYI:
      I created a new script you can download it using the attached link.
      https://gallery.technet.microsoft.com/Backup-All-GPOs-Powershell-cf5dfd8e
      
  • Restoring from backup
    2 Posts | Last post March 23, 2015
    • I'm guessing that I can't simply copy the backed up GPs into SYSVOL. Could you point me to a restore script (before I need it?)
    • You can use powershell:
      https://technet.microsoft.com/de-de/library/ee461044.aspx
      
      or the GPMC to Import the GPOs:
      Right-click "Group Policy Objects" and click on "Manage Backups..."
      
      
  • missing Import-Module grouppolicy
    2 Posts | Last post June 11, 2013
    • Could you place the Import-Module grouppolicy, it's missing on tihs page :D
    • THX. I added it now.