I'm using below script to take backup of the GPO's in my environment. But Im getting the error mentioned below ie "Access Denied". Is there anyway to identify which gpo has the permission issue and skip that error and continue with the GPO backup. Right now if there is any Access denied script stops execution and backup is not getting completed successfully.
Script:------------$date = Get-Date -Format dd.MM.yyyy$americasregionpath = "D:\GPO-Backups\Daily\Americas\$date"New-Item -Path $americasregionpath -ItemType directoryBackup-GPO -All -Domain americas.com -Path $americasregionpath -Server americas001.americas.com
GPO backup failure while using Backup-GPO cmdlet
- 499 Views
- Last Post 05 May 2016
If you just want to continue and not be bothered with the errors (sub-optimal) you can try suppressing errors using -ErrorAction SilientlyContinue as a parameter on the backup
Alternatively, you might want to take a different approach to see which GPO is causing the issue, which is to first get a list of all GPOs using:
$gpoList = get-gpo -all
Then put those in a foreach loop to backup each GPO:
Foreach ($gpo in $gpoList)
write-host Current GPO is $gpo.DisplayName.ToString()
Try adding –ErrorAction SilentlyContinue or perhaps preferably look at try/catch as you may be able to report on the GPO causing the issue, correct it and ensure it’s in the backup going forward.