Get-ADGroup command in a Windows PowerShell is used to query a Domain Controller and return Active Directory group objects.
Particularly it can be used to get a list of all the Active Directory groups in the Domain Controller the computer is connected to.
To get the Active Directory groups using the
Get-ADGroup command you need to have an “Active Directory Users and Computers” tool installed and you should be logged into a domain-joined computer as an Active Directory user with the relevant permission.
In this note i will show how to get the Active Directory groups using the
Get-ADGroup command from the PowerShell.
Cool Tip: Find out what domain controller am i connected to! Read more →
Get Active Directory Groups
To get all the Active Directory groups in the domain the computer is connected to, use the PowerShell’s
Get-ADGroup command as follows:
PS C:\> Get-ADGroup -Filter *
To get the Active Directory groups in another domain, add the
PS C:\> Get-ADGroup -Filter * -Server <domain>
To get the sorted list of the Active Directory group names only:
PS C:\> Get-ADGroup -Filter * | Select Name | Sort Name
Use the following construction to search for the Active Directory groups using the PowerShell’s
grep equivalent, e.g. to get the Active Directory group names starting with “Adm“):
PS C:\> Get-ADGroup -Filter * | Select Name | Out-String -Stream | Select-String "^Adm.*"
To find a single group, use the
Identity parameter, e.g. to check if an Active Directory group called ‘Administrators‘ exists, run the command below:
PS C:\> Get-ADGroup -Identity 'Administrators'
If you are getting an error as follows while trying to execute the commands above, you need to install the Active Directory Users and Computers on your computer:
Get-ADGroup : The term ‘Get-ADGroup’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Cool Tip: How to get the members of an AD group in PowerShell! Read more →