mvalencia2003
asked on
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,
to get all users from a specific OU?
Also to get this list into a file (TXT or XML)
??
-
Thanks,
ASKER
this is searching all accounts in domain: get-qaduser | where {$_.Path -like "*OU=IT*"}
How is OU entered?
Thanks , ...
How is OU entered?
Thanks , ...
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=my domain,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*"
if you look at a single account:
get-qaduser YourUser | select path
you will see something like this:
LDAP://mydomain.domain.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*"
ASKER
so what if OU is: mydomain.domain.com\compan y\students \group1
??
Thanks , ...
??
Thanks , ...
If group1 is unique, i.e. no other OU named group1 then use:
$_.path -like "*group1*"
$_.path -like "*group1*"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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