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 PoliciesNew-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, it does not get linked to any OUs or domains by default. It just stays in the Group Policy objects container in the GPMC console. After creating the GPO, it has to be linked to any of the existing OUs and this can be done by using the...