Remove-GPLink

Remove-GPLink

Removes a GPO link from a site, domain or OU.

Syntax

Parameter Set: LinkbyGUID
Remove-GPLink -Guid <Guid> -Target <String> [-Domain <String> ] [-Server <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Parameter Set: LinkbyName
Remove-GPLink [-Name] <String> -Target <String> [-Domain <String> ] [-Server <String> ] [-Confirm] [-WhatIf] [ <CommonParameters>]




Detailed Description

The Remove-GPLink cmdlet removes the link between a Group Policy Object (GPO) and a specified site, domain, or OU. This cmdlet does not delete the actual GPO or any other links between the specified GPO and other sites, domains, or OUs.

Parameters

-Domain<String>

Specifies the domain for this cmdlet. You must specify the fully qualified domain name (FQDN) of the domain.

For the Remove-GPLink cmdlet:

-- The GPO that is linked must exist in this domain.

-- The Active Directory container (site, domain, or OU) that is linked must exist in a domain that has a trust relationship with this domain.

Note: To specify a domain to link to, use the Target parameter.

If you do not specify the Domain parameter, the domain of the user that is running the current session is used. If the cmdlet is being run from a computer startup or shutdown script, the domain of the computer is used. For more information, see the Notes section in the full Help.

If you specify a domain that is different from the domain of the user that is running the current session (or, for a startup or shutdown script, the computer), a trust must exist between that domain and the domain of the user, or the computer.

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


Aliases

DomainName

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Guid<Guid>

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

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


Aliases

ID,GPOID

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByPropertyName)

Accept Wildcard Characters?

false

-Name<String>

Specifies the GPO for which to remove the link 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.


Aliases

DisplayName

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-Server<String>

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.


Aliases

DC

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Target<String>

Specifies the Lightweight Directory Access Protocol (LDAP) distinguished name of the site, domain, or OU from which to remove the link. For instance, for the MyOU organizational unit in the contoso.com domain, the LDAP distinguished name is ou=MyOU,dc=contoso,dc=com.


Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByPropertyName)

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.


Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

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


Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

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

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • Microsoft.GroupPolicy.GpoLink

    This cmdlet accepts an object that represents the link between a GPO and a site, domain, or OU.


Outputs

The output type is the type of the objects that the cmdlet emits.

  • Microsoft.GroupPolicy.Gpo

    This cmdlet returns the GPO for which the link has been removed.


Examples

Example 1: Remove the specified GPO link

This command removes the link between the GPO named MyGPO and the MyOU organizational unit in the contoso.com domain.


PS C:\> Remove-GPLink -Name "MyGPO" -Target "OU=MyOU,dc=contoso,dc=com" 

Example 2: Remove the link between the specified GPO and the default site

This command removes the link between the GPO named MyGPO and the default site.


PS C:\> Remove-GPLink -Name "MyGPO" -Target "Default-First-Site-Name"

Example 3: Remove the links for all GPOs that are linked to the specified organizational unit

This command removes the links for all the GPOs that are linked to the MyOU organizational unit in the contoso.com domain.

This cmdlet is used to get a Microsoft.GroupPolicy.Som object for the OU. The GpoLinks property of the SOM object contains all the GPO links for GPOs that are linked to the OU. Links that are inherited from higher-level containers are not included. This collection is piped into Remove-GPLink. The GPOs for which links have been removed are returned.


PS C:\> (Get-GPInheritance -Target "ou=myou,dc=contoso,dc=com").GpoLinks | Remove-GPLink 

Related topics

Community Additions

ADD
Show: