Powershell an Organization Unit in ADUC and get all groups with properties into csv

Crod 266 Reputation points

Having some difficulties trying to powershell just a single OU in ADUC and get all groups that are in it and associated properties into a csv please.

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
5,575 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,282 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Rich Matheisen 44,006 Reputation points

    Use the -SearchBase and maybe the -SearchScope parameters on the Get-ADGroup to target your search.

    The "associated properties" can be extensive and probably not all (or even many) of them would be useful to you. Also, getting the membership of a group into a CSV isn't as simple as adding the member property to the CSV.

    You'll find lots of examples of how to do what you're asking if you search the web. Maybe not all of them will do exactly what you want, but you should be able to use them as a basis for you own script.

    If you need help with your script, post the code you're using along with a clear explanation of your goal and the particular problem you're having (including any exception messages).

    0 comments No comments

  2. Ian Xue (Shanghai Wicresoft Co., Ltd.) 27,926 Reputation points Microsoft Vendor


    You could use the cmdlet Get-ADGroup. Please check if this works for you.

    #Get groups in YourOU.YourDC.com  
    Get-ADGroup -Filter * -SearchBase "OU = YourOU, DC = YourDC, DC = com" -Properties *  | Export-Csv C:\YourFolder\groups.csv  

    Best Regards,


    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments