Project

GPOZaurr

GPOZaurr helps inspect, report on, and remediate Group Policy environments with PowerShell.

Stars 1,250
Forks 119
Open issues 15
PowerShell Gallery downloads 421,558
Release v1.1.11
Language: PowerShell Updated: 2026-10-09
Command

Remove-GPOZaurrLegacyFiles

Module GPOZaurr

Removes legacy Group Policy Objects (GPO) files from specified domains.

Syntax

Remove-GPOZaurrLegacyFiles [-BackupDated] [[-BackupPath] <String>] [[-ExcludeDomains] <String[]>] [[-Forest] <String>] [[-IncludeDomains] <String[]>] [[-LimitProcessing] <Int32>] [-RemoveEmptyFolders] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

The Remove-GPOZaurrLegacyFiles function removes legacy GPO files from specified domains. It can back up the files before removal and optionally remove empty folders.

Examples

Authored help example

EXAMPLE 1

Remove-GPOZaurrLegacyFiles -BackupPath "C:\GPOBackups" -BackupDated -RemoveEmptyFolders -Forest "Contoso" -IncludeDomains "Domain1", "Domain2" -ExcludeDomains "Domain3" -LimitProcessing 100
Removes legacy GPO files from the "Contoso" forest for "Domain1" and "Domain2", excluding "Domain3". Backs up files to "C:\GPOBackups" with timestamps and removes empty folders after deletion.

Parameters

-BackupDated SwitchParameter optional
Indicates whether backup files should be timestamped with the current date and time.
-BackupPath String optionalposition: 0
Specifies the path where backup files will be stored.
-ExcludeDomains String[] optionalposition: 2
Specifies an array of domains to exclude from processing.
-Forest String optionalposition: 1aliases: ForestName
Specifies the forest where the GPO files are located.
-IncludeDomains String[] optionalposition: 3aliases: Domain, Domains
Specifies an array of domains to include for processing.
-LimitProcessing Int32 optionalposition: 4
Specifies the maximum number of GPO files to process.
-RemoveEmptyFolders SwitchParameter optional
Indicates whether empty folders should be removed after GPO files are deleted.

Common Parameters

This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.

For more information, see about_CommonParameters.