Skip navigation

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

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-3df031149bb5
DisplayName : Sales GPO
Enabled : True
Enforced : False
Target : DC=savilltech,DC=net
Order : 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-c01cf9361e7e
DisplayName : Test GPO
Enabled : True
Enforced : False
Target : DC=savilltech,DC=net
Order : 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
TAGS: Windows 7/8
Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.