0
0
PowershellHow-ToBeginner · 3 min read

How to Get Active Directory Group with PowerShell

Use the Get-ADGroup cmdlet in PowerShell to retrieve Active Directory groups. You can specify the group name or use filters to find groups. This requires the Active Directory module installed and imported.
📐

Syntax

The basic syntax of Get-ADGroup is:

  • Get-ADGroup -Identity <GroupName>: Retrieves a specific group by name or distinguished name.
  • Get-ADGroup -Filter <FilterExpression>: Retrieves groups matching the filter criteria.
  • Get-ADGroup -Properties <PropertyList>: Retrieves additional properties of the group.

You must have the Active Directory module imported to use this cmdlet.

powershell
Get-ADGroup -Identity "GroupName"

Get-ADGroup -Filter "Name -like '*Admin*'"

Get-ADGroup -Filter * -Properties Description
💻

Example

This example shows how to get a group named "HR Team" and display its name and description.

powershell
Import-Module ActiveDirectory
$group = Get-ADGroup -Identity "HR Team" -Properties Description
Write-Output "Group Name: $($group.Name)"
Write-Output "Description: $($group.Description)"
Output
Group Name: HR Team Description: Human Resources department group
⚠️

Common Pitfalls

  • Not importing the Active Directory module before running Get-ADGroup causes errors.
  • Using incorrect group names or filters returns no results.
  • Running the cmdlet without proper permissions may fail.
  • For remote computers, the Active Directory module must be available and connected.
powershell
## Wrong: Missing module import
Get-ADGroup -Identity "HR Team"

## Right: Import module first
Import-Module ActiveDirectory
Get-ADGroup -Identity "HR Team"
📊

Quick Reference

ParameterDescription
-IdentitySpecify the group name or distinguished name to get a specific group
-FilterUse a filter expression to find groups matching criteria
-PropertiesList additional properties to retrieve for the group
-SearchBaseLimit search to a specific Active Directory container or OU
-ServerSpecify the domain controller to query

Key Takeaways

Always import the Active Directory module with Import-Module ActiveDirectory before using Get-ADGroup.
Use -Identity to get a specific group or -Filter to search groups by criteria.
Ensure you have the necessary permissions to query Active Directory groups.
Use -Properties to retrieve extra details like Description or Members.
Check spelling and case sensitivity when specifying group names.