Get AD Usernames - List

What is the full command: "Get-QAD ...

to get all users from a specific OU?

Also to get this list into a file (TXT or XML)
??

-
Thanks,
LVL 4
mvalencia2003Asked:
Who is Participating?
 
SubsunConnect With a Mentor Commented:
Use -SearchRoot parameter to specify a OU.
Get-QADUser -SearchRoot 'CN=Users,DC=SS64,DC=com'

Open in new window

Ref : http://ss64.com/ps/get-qaduser.html
To Export
Get-QADUser -SearchRoot 'CN=Users,DC=SS64,DC=com' | Export-CSV C:\report.csv -nti

Open in new window

To export specific properties..
Get-QADUser -SearchRoot 'CN=Users,DC=SS64,DC=com' | Select DisplayName,SamAccountname,Mail  | Export-CSV C:\report.csv -nti

Open in new window

0
 
Gary DewrellSenior Network AdministratorCommented:
get-qaduser | where {$_.Path -like "*OU=IT*"}

Output to txt file
get-qaduser | where {$_.Path -like "*OU=IT*"} | Out-File c:\temp\ITMembers.txt

Output to xml
get-qaduser | where {$_.Path -like "*OU=IT*"} | Export-Clixml c:\temp\itmembers.xml
0
 
mvalencia2003Author Commented:
this is searching all accounts in domain: get-qaduser | where {$_.Path -like "*OU=IT*"}

How is OU entered?

Thanks , ...
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
Gary DewrellSenior Network AdministratorCommented:
get-qaduser does not have a built in filter for OU.  You could use the -ldap filter option but I have seen some weirdness from this so the above is what I use in my environment. Let me step you through it.

if you look at a single account:

get-qaduser YourUser | select path
you will see something like this:
LDAP://mydomain.domain.com/CN=Doe\, John,OU=IT,OU=Dallas,DC=mydomain,DC=COM

You have to read it backwards. From this return I see the user Jonhn doe is in the OU IT under the OU Dallas in the mydomain domain.

So If I want to return a list of everyone in the IT OU the above command gets all users and then filters the result by anyone with a path that has the phrase "OU=IT" .

If you were searching for those in the accounting OU you would change it to $_.Path -like "*OU=Accounting*"
0
 
mvalencia2003Author Commented:
so what if OU is: mydomain.domain.com\company\students\group1

??


Thanks , ...
0
 
Gary DewrellSenior Network AdministratorCommented:
If group1 is unique, i.e. no other OU named group1 then use:

$_.path -like "*group1*"
0
 
SubsunCommented:
Question was to get list of users from a specific OU using Get-QADUser command. Solution is to use -SearchRoot parameter as explained in my comment.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.