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

Table of Contents (16 chapters)
Active Directory with PowerShell
About the Author
About the Reviewers


This book is for IT professionals who manage the Windows Active Directory infrastructure. Professionals supporting the Active Directory infrastructure, operations teams, and help desk members will find the content of this book useful. Any experience in PowerShell would be beneficial to help you easily grasp the content. Also, beginners can use this book to learn how to manage Active Directory environment using PowerShell.

What this book covers

Chapter 1, Let's Get Started, gives you an overview of the components, software, and modules required to manage Active Directory with PowerShell and gets you kick-started with routine tasks for automation. It also gives you the directions you need to use this book.

Chapter 2, Managing User and Computer Objects, helps users to perform various user and computer account administration related activities using PowerShell. By the end of this chapter, you will have a good understanding of how to manage user and computer Active Directory accounts using PowerShell and perform some of the automations based on it.

Chapter 3, Working with Active Directory Groups and Memberships, focuses on creating, modifying, and querying various kinds of security groups in Active Directory and their memberships. This chapter delivers the skills which are necessary for managing security groups in the Active Directory environment using PowerShell.

Chapter 4, Configuring Group Policies, helps in creating, linking, and unlinking Group Policies at various scopes; also, it is an integral part of Active Directory. By the end of this chapter, you will learn how to create GPOs, link them, enforce them, and perform several other operations using PowerShell. You will also be able to determine what policies are applied to a user and computer, remotely.

Chapter 5, Managing Domains, Organizational Units, Sites, and Subnets, tells you how to manage domains, Organizational Units, sites, and IP subnets using PowerShell. After completing this chapter, you will know how to manage OUs, sites, and IP subnets in your Active Directory environment.

Chapter 6, Advanced AD Operations Using PowerShell, talks about performing some of the advanced operations in Active directory such as promoting and demoting Active Directory domain controllers, the recovery of AD objects, and working with replication using PowerShell. After completing this chapter, you will know how to perform advanced AD operations, which are essential for any Active Directory administrator in a large enterprise environment.

Chapter 7, Managing DFS-N and DFS-R Using PowerShell, demonstrates how to create, configure, and query Distributed File System Namespace (DFS-N) and Distributed File System Replication (DFS-R) using PowerShell. By the end of this chapter, you will know how to administer DFS-N and DFS-R in a complex environment with the help of PowerShell.

Chapter 8, Managing Active Directory DNS Using PowerShell, helps you to understand how to manage AD DNS servers using PowerShell. A variety of operations such as clearing cache, creating and modifying records, working with zones, and many similar operations are covered in this chapter. By the end of this chapter, you will be able manage Active Directory DNS servers using PowerShell to create, modify, and delete records, and perform some of the advanced DNS server operations.

Chapter 9, Miscellaneous Scripts and Resources for Further Learning, gives the information which you need about managing Active Directory using PowerShell. This will also provide references and code samples for some of the frequently performed Active Directory operations. By the end of this chapter, you will know where to look for further help.

What you need for this book

This book is written to demonstrate the management of Active Directory in the Windows Server 2012 R2 environment. While all code samples provided here work in the Windows Server 2012 R2 environment, some will work in Windows Server 2008 R2 and Windows Server 2012 environments as well. The system and services that are required to work on are as follows:

  • PowerShell v3 or later

  • Windows Server 2012 R2 with the following roles installed:

    • Active Directory

    • Domain Naming System (DNS) server

    • Distributed File System Namespace (DFS-N)

    • Distributed File System Replication (DFS-R)

Who this book is for

If you are looking to automate the 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.


In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The Get-ADUser command can be used to query user information. We can apply filters to narrow down the results using the -Filter and -LDAPFilter parameters".

A block of code is set as follows:

function Get-ADObjectsCount {
$Users = Get-ADUser -Filter *
$Groups = Get-ADGroup -Filter *
$Computers = Get-ADComputer -Filter *
$DomainName = (Get-ADDomain).Name
"{0} Users, {1} Computers and {2} Groups found in {3} Domain" -f $Users.Count,$Computers.Count,$Groups.Count,$DomainName

Any command-line input or output is written as follows:

PS C:\> Get-ADObjectsCount
110 Users, 13 Computers and 83 Groups found in techibee Domain

PS C:\> 

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes, for example, appear in the text like this: "add the Group Policy Management option to install this feature".


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from


Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.


You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.