Link to home
Start Free TrialLog in
Avatar of MilesLogan
MilesLoganFlag for United States of America

asked on

Add AD Accounts to a group if the Distinguished name matches a certain criteria

Hi EE , need some help if someone wants to help solve this puzzle ..


1) Check Group1
2) If Distinguised name or CanonicalName contains "area1" , "area2" , "area3"
3) Add those accounts to Group2
4) Export CSV of SamaccountName added to Group2


*** Group1 contains over 50K users ***
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MilesLogan

ASKER

hi oBdA , no Group1 would never be the primary group .

I will try it in a couple hours , thank you
Thank you oBdA  , I tried it on a small group and it worked ..I wont try on the large group until tonight .
What does this do ?

$chunkSize = 5000
If ($members.Count -eq $chunkSize)
Avatar of oBdA
oBdA

Adding one account at a time is rather ineffective, but there's a limit on the request size the AD web service accepts.
It's usually not an issue, but with potentially that many accounts to add, this makes sure that the accounts are only added in batches of this size.
If it bails out anyway, try to lower this size.
ok cool .. thank you so much !