Modifica

Condividi tramite


Remove-GPO

Removes a GPO.

Syntax

ByGUID (Default)

Remove-GPO
    -Guid <Guid>
    [-Domain <String>]
    [-Server <String>]
    [-KeepLinks]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByName

Remove-GPO
    [-Name] <String>
    [-Domain <String>]
    [-Server <String>]
    [-KeepLinks]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

The Remove-GPO cmdlet removes the Group Policy Object (GPO) container and data from the directory service and the system volume folder (SysVol).

Examples

Example 1: Remove a GPO by GUID

PS C:\> Remove-GPO -Guid 50cc3e45-0b14-46dd-8b4d-afa012bc331c -Domain "contoso.com" -KeepLinks

This command removes the GPO that has the GUID 50cc3e45-0b14-46dd-8b4d-afa012bc331c from the contoso.com domain. Because the KeepLinks parameter is specified, links between the GPO and all sites, and links between the GPO and all containers in the domain are preserved.

Example 2: Remove a GPO by name

PS C:\> Remove-GPO -Name "TestGPO"

This command removes the GPO named TestGPO from the domain of the user that is running the session. Because the KeepLinks parameter is not specified, links between the GPO and all sites, and links between the GPO and all containers in the domain are removed.

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Domain

Specifies the domain in which you want to remove a GPO. You must specify the fully qualified domain name (FQDN) of the domain.

If you do not specify the Domain parameter, the domain of the computer that you are logged on to is used.

If you specify a domain that differs from the domain of your user object, a trust must exist between the domain from which you want to remove the GPO and the domain of your user object.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:DomainName

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Guid

Specifies the GPO to remove by its globally unique identifier (GUID). The GUID uniquely identifies the GPO.

You can also refer to the Guid parameter by its built-in alias, id. For more information, see about_Aliases.

Parameter properties

Type:Guid
Default value:None
Supports wildcards:False
DontShow:False
Aliases:ID, GPOID

Parameter sets

ByGUID
Position:Named
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

Indicates that the cmdlet preserves the links to the GPO in the specified domain, including OUs, and all sites when the GPO is removed.

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Name

Specifies the GPO that this cmdlet removes by its display name.

The display name is not guaranteed to be unique in the domain. If another GPO with the same display name exists in the domain an error occurs. You can use the Guid parameter to uniquely identify a GPO.

You can also refer to the Name parameter by its built-in alias, displayname. For more information, see about_Aliases.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:DisplayName

Parameter sets

ByName
Position:0
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:True
Value from remaining arguments:False

-Server

Specifies the name of the domain controller that this cmdlet contacts to complete the operation. You can specify either the fully qualified domain name (FQDN) or the host name.

If you do not specify the name by using the Server parameter, the primary domain controller (PDC) emulator is contacted.

You can also refer to the Server parameter by its built-in alias, dc. For more information, see about_Aliases.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False
Aliases:DC

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

Microsoft.GroupPolicy.Gpo

This cmdlet pipes the GPO to be removed. Collections that contain GPOs from different domains are not supported.

Outputs

None

This cmdlet does not generate any output.

Notes

  • When you remove a GPO, by default, all links to that GPO in the domain of the GPO are deleted. To remove a link to a GPO, you must have permission to link Group Policy Objects for the organizational unit or domain. If you do not have rights to delete a link, the GPO is deleted, but the link remains. Links from other domains and sites are not removed. The link to a deleted GPO appears in the GPMC as Not Found. To remove Not Found links, you must either have permission on the site, domain, or organizational unit containing the link, or ask someone with sufficient rights to delete it.