Set-GPLink
Set-GPLink
Sets the properties of the specified GPO link.
Syntax
Set-GPLink [-Name] <string> -Target <string> [-Domain <string>] [-Enforced {<Unspecified> | <No> | <Yes>}] [-LinkEnabled {<Unspecified> | <No> | <Yes>}] [-Order <int>] [-Server <string>] [-Confirm] [-WhatIf] [<CommonParameters>]
Set-GPLink -Guid <Guid> -Target <string> [-Domain <string>] [-Enforced {<Unspecified> | <No> | <Yes>}] [-LinkEnabled {<Unspecified> | <No> | <Yes>}] [-Order <int>] [-Server <string>] [-Confirm] [-WhatIf] [<CommonParameters>]
Detailed Description
The Set-GPLink cmdlet sets the properties of a GPO link.
You can set the following properties:
-- Enabled. If the GPO link is enabled, the settings of the GPO are applied when Group Policy is processed for the site, domain or OU.
-- Enforced. If the GPO link is enforced, it cannot be blocked at a lower-level (in the Group Policy processing hierarchy) container.
-- Order. The order specifies the precedence that the settings of the GPO take over conflicting settings in other GPOs that are linked (and enabled) to the same site, domain, or OU.
Parameters
-Domain <string>
Specifies the domain for this cmdlet. You must specify the fully qualified domain name (FQDN) of the domain (for example: sales.contoso.com).
For the Set-GPLink cmdlet:
-- The GPO that is linked from must exist in this domain.
-- The Active Directory container that is linked to 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 executed 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.
Attributes
Name | Value |
---|---|
Required? |
false |
Accept wildcard characters? |
false |
Accept Pipeline Input? |
true (ByPropertyName) |
Position? |
named |
-Enforced <EnforceLink>
Specifies whether the GPO link is enforced. You can specify Yes or No. By default, GPO links are not enforced.
By setting the GPO link to enforced, you ensure the following:
-- That the settings of the GPO cannot be blocked (by blocking inheritance) at a lower-level Active Directory container.
-- That the settings of the GPO always take precedence over conflicting settings in GPOs that are linked to lower-level containers.
This option should be used sparingly. Casual use of this option complicates troubleshooting.
The following values are permitted for this object type.
Unspecified **
No **
Yes **
Attributes
Name | Value |
---|---|
Required? |
false |
Accept wildcard characters? |
false |
Accept Pipeline Input? |
false |
Position? |
named |
-Guid <Guid>
Specifies the GPO of 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 alias, "id". For more information, see about_Aliases.
Attributes
Name | Value |
---|---|
Required? |
true |
Accept wildcard characters? |
false |
Accept Pipeline Input? |
false |
Position? |
named |
-LinkEnabled <EnableLink>
Specifies whether the GPO link is enabled. You can specify Yes or No.
By default, Group Policy processing is enabled for all GPO links. You can completely block the application of a GPO for a specific site, domain, or OU by disabling the GPO link for that site, domain, or OU. Disabling a GPO link does not disable the GPO itself. If the GPO is linked to other sites, domains, or OUs, Group Policy continues to process the GPO for each link that is enabled.
The following values are permitted for this object type.
Unspecified **
No **
Yes **
Attributes
Name | Value |
---|---|
Required? |
false |
Accept wildcard characters? |
false |
Accept Pipeline Input? |
false |
Position? |
named |
-Name <string>
Specifies the GPO of 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.
Attributes
Name | Value |
---|---|
Required? |
true |
Accept wildcard characters? |
false |
Accept Pipeline Input? |
true (ByPropertyName) |
Position? |
1 |
-Order <int>
Specifies the link order for the GPO link. You can specify a number that is between one and the current number of GPO links to the target site, domain, or OU, plus one.
The link order specifies the order of precedence with which GPOs linked to the same Active Directory container are applied. When Group Policy is processed, GPOs with a higher link order number are processed before GPOs with a lower link order number. Therefore, when two GPOs contain conflicting settings, the settings in the GPO with the lower link order number, because it is processed last, overwrites those of the GPO with the higher link order number. A lower number indicates higher precedence.
By default, the GPO link is added at the lowest precedence (with a link order equal to the number of GPO links to the container, plus one). Link order is a dynamic value because the value may change as GPO links are added and deleted from the container.
Attributes
Name | Value |
---|---|
Required? |
false |
Accept wildcard characters? |
false |
Accept Pipeline Input? |
false |
Position? |
named |
-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. For example:
FQDN: DomainController1.sales.contoso.com
Host Name: DomainController1
If you do not specify the name by using the Server parameter, the PDC emulator is contacted.
You can also refer to the Server parameter by its built-in alias, "dc". For more information, see about_Aliases.
Attributes
Name | Value |
---|---|
Required? |
false |
Accept wildcard characters? |
false |
Accept Pipeline Input? |
false |
Position? |
named |
-Target <string>
Specifies the LDAP distinguished name of the site, domain, or OU of the link. For example, for the "MyOU" organizational unit in the contoso.com domain, the LDAP distinguished name is "ou=MyOU,dc=contoso,dc=com".
Attributes
Name | Value |
---|---|
Required? |
true |
Accept wildcard characters? |
false |
Accept Pipeline Input? |
true (ByPropertyName) |
Position? |
named |
-Confirm <SwitchParameter>
Prompts you for confirmation before executing the command.
Attributes
Name | Value |
---|---|
Required? |
false |
Accept wildcard characters? |
false |
Accept Pipeline Input? |
false |
Position? |
named |
-WhatIf <SwitchParameter>
Describes what would happen if you executed the command without actually executing the command.
Attributes
Name | Value |
---|---|
Required? |
false |
Accept wildcard characters? |
false |
Accept Pipeline Input? |
false |
Position? |
named |
-CommonParameter
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see About Common Parameter
Input and Return Types
The input type is the type of the objects that you can pipe to the cmdlet. The return type is the type of the objects that the cmdlet emits.
Input Type |
Microsoft.GroupPolicy.GpoLink. A GPO link between a GPO and a site, domain, or OU. |
Return Type |
Microsoft.GroupPolicy.GpoLink. Set-GPLink returns the GPO link after the change has been applied. |
Notes
You can use the Domain parameter to explicitly specify the domain for this cmdlet.
If you do not explicitly specify the domain, the cmdlet uses a default domain. The default domain is the domain that is used to access network resources by the security context under which the current session is running. This domain is typically the domain of the user that is running the session. For example, the domain of the user who started the session by opening Windows PowerShell from the Program Files menu, or the domain of a user that is specified in a runas command. However, computer startup and shutdown scripts execute under the context of the LocalSystem account. The LocalSystem account is a built-in local account, and it accesses network resources under the context of the computer account. Therefore, when this cmdlet is executed from a startup or shutdown script, the default domain is the domain to which the computer is joined.
Examples
EXAMPLE 1
C:\PS>
Set-GPLink -Name TestGPO -Target "ou=MyOU,dc=contoso,dc=com" -LinkEnabled Yes
GpoId : c25daa3e-5d05-43b3-87ca-0a237882fd63
DisplayName : Test2GPO
Enabled : True
Enforced : False
Target : OU=MyOU,DC=contoso,DC=com
Order : 1
Description
-----------
This command enables the link between the "TestGPO" GPO and the MyOU organizational unit in the contoso.com domain. The Enforced and Order properties are not changed.
EXAMPLE 2
C:\PS>
Set-GPLink -Name TestGPO -Domain north.contoso.com -Target "dc=south, dc=contoso, dc=com" -LinkEnabeled Yes -Enforced Yes -Order 1
Description
-----------
This command enables the link between the "TestGPO" GPO in the north.contoso.com domain and the south.contoso.com domain. The link is set to enforced, so it cannot be blocked at lower-level containers (for example OUs in the south.contoso.com domain). Because the order is set to 1, the settings of the "testGPO" GPO will be applied with the highest precedence (except for enforced links) when Group policy is processed for the south.contoso.com domain container.
EXAMPLE 3
C:\PS>
set-gplink -guid 77c5285d-952e-4559-94ef-a02f5c107799 -target "test-site" -enforced yes
GpoId : 77c5285d-952e-4559-94ef-a02f5c107799
DisplayName : TestGPO
Enabled : True
Enforced : True
Target : CN=test-site,cn=Sites,CN=Configuration,DC=contoso,DC=com
Order : 1
Description
-----------
This command sets the enforced property of the link between the GPO that has ID 77c5285d-952e-4559-94ef-a02f5c107799 and the test site. Inheritance cannot be blocked for this link at containers that are at lower-levels of the Group Policy hierarchy.