Creating and linking Group Policies

So far, we have seen how to query the existing Group Policies using the Active Directory and Group Policy modules. Now, let's check how to create a new policy in Active Directory and link it to Organizational Units using PowerShell code.

To do this, we mainly need two cmdlets:

  • New-GPO: This will help in creating the Group Policies
  • New-GPLink: This will help in creating links to existing OUs, domains, and sites

To create a new GPO, we just need to pass the name of the GPO to the New-GPO cmdlet and it returns the GPO object details after creating the new GPO. The following command creates a new GPO with the name MyNewGPO:

New-GPO -Name "MyNewGPO"

It should look like following screenshot:

When a new GPO is created, ...

Get Active Directory with PowerShell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.