Using PowerShell to create and link GPOs

by Mitch Tulloch [Published on 4 Dec. 2014 / Last Updated on 4 Dec. 2014]

A tip on how you can use Windows PowerShell to create new Group Policy Objects and link them to organizational units.

To show how you can create and link GPOs using Windows PowerShell, you will create a new GPO named "BO-1-Desktops" based on the Starter GPO named "Computers-Desktop" which you created in Lesson 1 of this chapter. You will then link the new GPO to the OU named "BO-1-SEA", which represents the Branch Office #1 in Seattle in the corp.fabrikam.com domain.

You can start by using the Get-StarterGPO cmdlet to confirm that your Starter GPO exists:

PS C:\> Get-GPStarterGPO -Name "Computers-Desktop" 

Next, you can use the New-GPO cmdlet to create the new GPO from your Starter GPO as follows:

PS C:\> New-GPO -Name "BO-1-Desktops" -StarterGpoName "Computers-Desktop"

Finally, you can link the new GPO to the targeted OU as follows:

PS C:\> New-GPLink -Name "BO-1-Desktops" `
-Target "ou=BO-1-SEA,dc=corp,dc=fabrikam,dc=com"

Alternatively, by using the Windows PowerShell pipeline feature, you can create and link the GPO using a single command like this:

Get-GPStarterGPO -Name "Computers-Desktop" | New-GPO -Name "BO-1-Desktops" | `
New-GPLink -Target "ou=BO-1-SEA,dc=corp,dc=fabrikam,dc=com"

The above tip was excerpted from Mitch Tulloch's book Training Guide: Installing and Configuring Windows Server 2012 from Microsoft Press.

Mitch is a nine-time recipient of the Microsoft Most Valuable Professional (MVP) award and a widely recognized expert on Windows administration, deployment and virtualization.  For more information see http://www.mtit.com.

See Also


The Author — Mitch Tulloch

Mitch Tulloch is a well-known expert on Windows Server administration and cloud computing technologies. He has published over a thousand articles on information technology topics and has written, contributed to or been series editor for over 50 books.