?
Solved

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

Posted on 2011-10-18
3
Medium Priority
?
374 Views
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.

Thanks.
0
Comment
Question by:amendala
3 Comments
 
LVL 3

Expert Comment

by:LindyS
ID: 36987304
Even though you don't trust addins, Quest Active roles shell makes this really simple.

Get-QADUser -enabled -searchroot 'domain.name/OU' | Select DN,Name, ParentContainer | Export-CSV filename.csv
0
 
LVL 27

Accepted Solution

by:
KenMcF earned 2000 total points
ID: 36988146
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

0
 

Author Closing Comment

by:amendala
ID: 36988616
That'll work!  Thanks!!!
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office 365 is a subscriptions based service which includes services like Exchange Online and Skype for business Online. These services integrate with Microsoft's online version of Active Directory called Azure Active Directory.
Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…

615 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