Book Image

Active Directory with PowerShell

By : Pamarthi Venkata Sitaram, YELLAPRAGADA U PADMAVATHI
5 (1)
Book Image

Active Directory with PowerShell

5 (1)
By: Pamarthi Venkata Sitaram, YELLAPRAGADA U PADMAVATHI

Overview of this book

If you are looking to automate repetitive tasks in Active Directory management using the PowerShell module, then this book is for you. Any experience in PowerShell would be an added advantage.
Table of Contents (11 chapters)
10
Index

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, 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 New-GPLink...