Answered by:
Get list of all users associated to Organizational Units

Question
-
I tried this cmd: Get-ADUser -Filter * -SearchBase "DC=my,DC=domain,DC=com" | Export-Csv C:\ADusers.csv
Get this error: Get-ADUser : The supplied distinguishedName must belong to one of the following partition(s):
I have already obtained all OUs just need all users associated to OUs please.
Thursday, May 11, 2017 9:21 PM
Answers
-
All users all OUs:
Get-ADUser -Filter * | Export-Csv C:\ADusers.csv -NoType
\_(ツ)_/
- Marked as answer by Chicojr Friday, May 12, 2017 1:46 PM
Thursday, May 11, 2017 10:27 PM
All replies
-
The error message indicates that the SearchBase distinguishedName is incorrect. And you have not specified the DN of an OU.
Do you want all users in a specified OU, or all users by OU, or all users in OU's (as opposed to in containers or the root of the domain)?
You can use Get-ADOrganizationalUnit to retrieve all OU's, then loop thru that and retrieve the users in each. When you export to a CSV you should specify the properties you want to document.
Richard Mueller - MVP Enterprise Mobility (Identity and Access)
Thursday, May 11, 2017 9:38 PM -
Thanks Richard,
I need all users in all OUs please.
Thursday, May 11, 2017 9:42 PM -
then dont specify searchbase at allThursday, May 11, 2017 10:18 PM
-
All users all OUs:
Get-ADUser -Filter * | Export-Csv C:\ADusers.csv -NoType
\_(ツ)_/
- Marked as answer by Chicojr Friday, May 12, 2017 1:46 PM
Thursday, May 11, 2017 10:27 PM