Q. How can I link a Policy Object (GPO) in PowerShell with Windows 7 or Windows Server 2008 R2?

John Savill

January 25, 2010

1 Min Read
ITPro Today logo in a gray background | ITPro Today

A. With Windows 7 and Server 2008 R2, you can use the included Group Policy cmdlets to perform many group policy actions from PowerShell. To use them, first start an elevated PowerShell console. Then import the grouppolicy module and use the New-GPLink cmdlet with the name of the GPO to link and the target, as shown here.

I enter

new-gplink -name "Sales GPO" -target "dc=savilltech,dc=net"

and receieve

GpoId : d3672844-2875-4b72-a8c4-3df031149bb5DisplayName : Sales GPOEnabled : TrueEnforced : FalseTarget : DC=savilltech,DC=netOrder : 4

You can also use the -enforced yes switch to force enforcement and -LinkEnabled to set enabled state (e.g. -LinkEnabled No).

Note that you can pass the output of a New-GPO cmdlet to the New-GPLink cmdlet to both create and link using one command, as shown below.

I enter

New-GPO "Test GPO" | New-GPLink -target "dc=savilltech,dc=net"

and receive

GpoId : e1dfcba2-a397-41e9-a978-c01cf9361e7eDisplayName : Test GPOEnabled : TrueEnforced : FalseTarget : DC=savilltech,DC=netOrder : 5

You could also use the set-gppermissions cmdlet to modify the permissions on the link you created.

Related Reading:



Check out hundreds more useful Q&As like this in John Savill's FAQ for Windows. Also, watch instructional videos made by John at ITTV.net.

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like