API Reference
Command
Remove-ADXGpo
Removes whole GPOs selected by state, with optional backup.
Examples
Example 1: Dry run: show top 10 candidates with reasons
Remove-ADXGpo -State Unlinked,EmptyGpo -SortBy Reasons -Descending -Max 10 -WhatIf | Format-Table DisplayName,DomainName,Reasons
Example 2: Prompted removal for GPOs with only disabled links
Remove-ADXGpo -State DisabledLinksOnly -Confirm
Example 3: Remove and emit removed objects plus count
Remove-ADXGpo -State Unlinked -Max 3 -PassThru | Tee-Object -Variable removed | Out-Null; $removed.Count
Example 4: Preview up to 5 unlinked GPOs
Remove-ADXGpo -State Unlinked -Max 5 -WhatIf | Select-Object DisplayName,DomainName,Reasons
Example 5: Confirm-before-delete GPOs with only disabled links
Remove-ADXGpo -State DisabledLinksOnly -Confirm
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.
Syntax
Remove-ADXGpo -State <string[]> [-BackupPath <string>] [-Descending] [-Domain <string[]>] [-Max <int>] [-PassThru] [-SortBy <string>] [<CommonParameters>]#Parameters
- State string[]
- Removal criteria for selecting GPOs.
- BackupPath string
- Optional directory path where a backup of each GPO is created before deletion.
- Descending SwitchParameter
- Reverse sort order.
- Domain string[]
- Optional domain names to scope the operation. When omitted, all domains in the forest are scanned.
- Max int
- Remove at most this many GPOs. Use 0 for no limit.
- PassThru SwitchParameter
- Emit removed candidate objects in addition to the final count.
- SortBy string
- Sort candidates before limiting and processing. Default: Name.