Please provide a Powershell script to find all the user accounts in a specific OU that are ENABLED.

Posted on 2011-10-18
Last Modified: 2012-05-12
Folks -

I'm looking for a powershell script that will search a specific OU in Active Directory and return the CN of all USER accounts that are ENABLED.  The script should ignore groups and all other non-user account objects.

I want to do this using only built-in Cmdlets.  I'm aware that there are prebuilt Cmdlets that can do this for me but I don't trust them.

Question by:amendala
    LVL 3

    Expert Comment

    Even though you don't trust addins, Quest Active roles shell makes this really simple.

    Get-QADUser -enabled -searchroot '' | Select DN,Name, ParentContainer | Export-CSV filename.csv
    LVL 27

    Accepted Solution

    You didnt say what OS you are running. If you have the AD cmdlets with 2008R2 or Win7 you can do this

    Get-ADUser -SearchBase "OU=New_Users,DC=DEVLAB,DC=LOCAL" -Filter {Enabled -eq $True} -Properties cn| Select CN, name, DistinguishedName

    Open in new window

    If you do not have those you can do this.

    PS C:\Users\Administrator> Get-ADUser -SearchBase "OU=LA,DC=DEVLAB,DC=LOCAL" -Filter {Enabled -eq $True} -Properties cn|
     Select CN, name, DistinguishedName

    Open in new window


    Author Closing Comment

    That'll work!  Thanks!!!

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    We recently had an issue where out of nowhere, end users started indicating that their logins to our terminal server were just showing a "blank screen." After checking the usual suspects -- profiles, shell=explorer.exe in the registry, userinit.exe,…
    New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
    This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
    This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now