Export AD Users with OU Names

create share 676 Reputation points
2022-12-20T23:22:49.217+00:00

Hi,

Is it possible to export all AD Users with OU names they reside in?

Thanks.

Windows for business | Windows Client for IT Pros | Directory services | Active Directory
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Andreas Baumgarten 123.6K Reputation points MVP Volunteer Moderator
    2022-12-20T23:45:35.16+00:00

    Hi @create share ,

    using PowerShell this should be possible.
    Maybe these links are helpful:
    https://www.alitajran.com/export-ad-users-to-csv-powershell
    https://learn.microsoft.com/en-us/answers/questions/963471/get-base-ou-name-for-a-list-of-users.html

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    0 comments No comments

  2. Limitless Technology 44,766 Reputation points
    2022-12-22T14:57:19.883+00:00

    Hello

    Thank you for your question and reaching out. I can understand you are having query\issues related to get All users with OU from AD.

    You can use below powershell code.


    $OUpath = 'dc=enterprise,dc=com'
    $ExportPath = 'c:\data\users.csv'
    Get-ADUser -Filter * -SearchBase $OUpath | Select-object
    DistinguishedName,Name,UserPrincipalName | Export-Csv -NoType $ExportPath


    Referene :

    https://learn.microsoft.com/en-us/answers/questions/239938/export-ad-users-to-csv-file.html

    https://learn.microsoft.com/en-us/answers/questions/963471/get-base-ou-name-for-a-list-of-users.html

    -------------------------------------------------------------------------------------------------------------------------------------------------

    --If the reply is helpful, please Upvote and Accept as answer--


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.