Answered by:
List users in a OU using powershell with dsquery

Question
Answers
-
I assume you want the sAMAccountName of the user (the "pre-Windows 2000 logon" name). Using Get-ADUser:
Get-ADUser -filter * -SearchBase "ou=West,dc=MyDomain,dc=com" | Select sAMAccountName
and using dsquery:dsquery user "ou=West,dc=MyDomain,dc=com" | dsget user -samid
In both cases you can redirect the output to a txt file.
Richard Mueller - MVP Directory Services- Proposed as answer by Darshana Jayathilake Wednesday, November 23, 2011 6:22 AM
- Marked as answer by Rick TanModerator Wednesday, November 23, 2011 9:06 AM
All replies
-
User dsquey user (at the command prompt of a DC) and specify the DN of the OU. For example:
dsquery user OU=Sales,OU=Usuarios,DC=mycompany,DC=ecu,DC=com
This also works in PowerShell, except the DN of the OU must be in quotes.
Richard Mueller - MVP Directory Services- Edited by Richard MuellerMVP Tuesday, November 22, 2011 11:31 PM added last sentence
-
Hi,
You may refer this thread, How to find all users/Groups from a specific OU ?
http://social.technet.microsoft.com/Forums/ar/winserverDS/thread/660ebac0-b877-4298-bd32-6529a17731c4Regards,
Abhijit Waikar - MCSA 2003|MCSA 2003:Messaging|MCTS|MCITP:SA -
-
-
I assume you want the sAMAccountName of the user (the "pre-Windows 2000 logon" name). Using Get-ADUser:
Get-ADUser -filter * -SearchBase "ou=West,dc=MyDomain,dc=com" | Select sAMAccountName
and using dsquery:dsquery user "ou=West,dc=MyDomain,dc=com" | dsget user -samid
In both cases you can redirect the output to a txt file.
Richard Mueller - MVP Directory Services- Proposed as answer by Darshana Jayathilake Wednesday, November 23, 2011 6:22 AM
- Marked as answer by Rick TanModerator Wednesday, November 23, 2011 9:06 AM
-
You can use dsquery or dsget to achieve the same.
dsquery user "ou=West,dc=MyDomain,dc=com" | dsget user -samid
Reference link for more info:
http://technet.microsoft.com/en-us/library/cc725702(WS.10).aspx
http://technet.microsoft.com/en-us/library/cc732535(WS.10).aspx
Alternately you can use ADManager Plus tool
http://www.manageengine.co.in/products/ad-manager/
Hope this helps
Regards,
Sandesh Dubey.
-------------------------------
MCSE|MCSA:Messaging|MCTS|MCITP:Enterprise Adminitrator
My Blog: http://sandeshdubey.wordpress.com
This posting is provided AS IS with no warranties, and confers no rights.