Home » PowerShell » PowerShell – List Active Directory Groups and Description

PowerShell – List Active Directory Groups and Description

As System administrator, you have to very often query about PowerShell active directory to list active directory groups and their description to search and migrate groups or users.

In this article, I will explain you, how to get list of all groups from active directory and export it to csv file using PowerShell.

PowerShell Get-AdGroup cmdlet gets one or more groups based on search conditions. We will use filter parameter to list active directory groups, samaccountname and description about active directory group.

List Active Directory Group and Description

Using PowerShell Get-ADGroup with filter parameter to list active directory group, description and active directory group properties, run below command

Get-ADGroup -filter * -properties * |select SAMAccountName, Description|Export-Csv adGroupList.csv

In the above PowerShell command, Get-AdGroup cmdlet get list of all ad groups based on filter * parameter and pass its output to second command.

Second command use Select to get samaccountname and description of ad group and pass its output to third command.

Third command use Export-csv cmdlet to export ad groups to csv file format.

Cool Tip: Using PowerShell Get-ADComputer to find computer name in OU !

List Active Directory Groups from OU

If you want to get active directory groups from specific OU or domain, run below command

Get-ADGroup -filter * -properties * -searchbase "OU=Sales,DC=Shell,DC=Com"|Select SAMAccountName, Description|Export-Csv -Path D:\PowerShell\adGroupList.csv

In the above PowerShell command, Get-ADGroup cmdlet gets ad group from active directory based on filter * parameter and find ad group from specified OU and pass its output to second command.
Second command, select samaccountname, description, members and pass its output to third command.

Third command, use Export-Csv cmdlet to export ad groups to csv file format. Above commands list active directory groups from specified OU and export ad groups to csv file.

Cool Tip: Using set-adgroup modify active directory group attributes PowerShell!

Conclusion

I hope, you enjoyed above article on using PowerShell Get-ADGroup cmdlet to list active directory groups, description and export ad groups to csv file.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on ShellGeek home page.

Leave a Comment