TestimoX

API Reference

Command

Remove-ADXGpo

Namespace ADPlayground.PowerShell

Removes whole GPOs selected by state, with optional backup.

Examples

Authored help example

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[] requiredposition: namedpipeline: false
Removal criteria for selecting GPOs.
BackupPath string optionalposition: namedpipeline: false
Optional directory path where a backup of each GPO is created before deletion.
Descending SwitchParameter optionalposition: namedpipeline: false
Reverse sort order.
Domain string[] optionalposition: namedpipeline: false
Optional domain names to scope the operation. When omitted, all domains in the forest are scanned.
Max int optionalposition: namedpipeline: false
Remove at most this many GPOs. Use 0 for no limit.
PassThru SwitchParameter optionalposition: namedpipeline: false
Emit removed candidate objects in addition to the final count.
SortBy string optionalposition: namedpipeline: false
Sort candidates before limiting and processing. Default: Name.