Reputation: 2655
My organization has a different OU for each site we have. Within each site is a nested out called OU=USERS
.
I want to find all members in every sites nested USERS
OU.
Simply using the following command does not work:
Get-ADUser -Filter * -SearchBase "OU=USERS,DC=*****,DC=*****"
Obviously, this does not return anything. I must specify a site:
Get-ADUser -Filter * -SearchBase "OU=USERS,OU=MySite,DC=*****,DC=*****"
Is it possibly to search through every site OU looking for the sub USERS ou?
Upvotes: 0
Views: 1425
Reputation: 46710
You could use another cmdlet to get the OU's you are looking for.
$ous = Get-ADOrganizationalUnit -Filter "Name -eq 'Users'"
$ous | ForEach-Object{
Get-ADUser -Filter * -SearchBase $_.DistinguishedName
}
Get-ADOrganizationalUnit
will get all the USERS OU's for you then you can run Get-ADUser
against each of those.
Upvotes: 3