$allou = "DC=domain,DC=com"
$User = get-aduser -filter * -SearchBase $allou -SearchScope Subtree | Select @{Name="OU";Expression={$_.distinguishedName -match "cn=.*?,OU=(?<OU>.*)" | Out-Null;$Matches.OU}}
$User | Group -Property OU | Select Name,Count
No comments:
Post a Comment