Book Image

Active Directory Administration Cookbook - Second Edition

By : Sander Berkouwer
Book Image

Active Directory Administration Cookbook - Second Edition

By: Sander Berkouwer

Overview of this book

Updated to the Windows Server 2022, this second edition covers effective recipes for Active Directory administration that will help you leverage AD's capabilities for automating network, security, and access management tasks in the Windows infrastructure. Starting with a detailed focus on forests, domains, trusts, schemas, and partitions, this book will help you manage domain controllers, organizational units, and default containers. You'll then explore Active Directory sites management as well as identify and solve replication problems. As you progress, you'll work through recipes that show you how to manage your AD domains as well as user and group objects and computer accounts, expiring group memberships, and Group Managed Service Accounts (gMSAs) with PowerShell. Once you've covered DNS and certificates, you'll work with Group Policy and then focus on federation and security before advancing to Azure Active Directory and how to integrate on-premise Active Directory with Azure AD. Finally, you'll discover how Microsoft Azure AD Connect synchronization works and how to harden Azure AD. By the end of this AD book, you’ll be able to make the most of Active Directory and Azure AD Connect.
Table of Contents (18 chapters)

Finding empty groups

This recipe demonstrates how to find groups without group members. Every object in Active Directory takes up resources. When a group is not used, it may be deleted.

Getting ready

To view group memberships for a group, sign in to a domain controller, a member server, or a device with RSAT for Active Directory Domain Services installed.

Sign in with a domain account.

How to do it...

Use the following line of PowerShell to find all groups without memberships in Active Directory on a system with the Active Directory module for Windows PowerShell installed:

Get-ADGroup -Filter * -Properties members | Where-Object {$_.Members.count -eq 0}  | Out-GridView

Replace DC=LucernPub,DC=com to represent your environment. Replace the other fields to represent your group's properties.

How it works...

The Get-ADGroup PowerShell cmdlet is used to get the members attribute. Then, recursively, for each group, the membership count is queried...