• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 658
  • Last Modified:

PowerShell - Quest - Any way to make this script a bit faster ? adding users to a group

Hi EE

I am using the script below and adding 20k users to a group but it just seems to be going much slower then I thought .. taking about 5 seconds per account.

Any way to go about this a different way ?

Foreach ($User in GC c:\Powershell\Users.txt){
GC C:\PowerShell\groups.txt | % {
Add-QADGroupmember -identity $_ -member $User
      }
}
0
MilesLogan
Asked:
MilesLogan
2 Solutions
 
Rajitha ChimmaniCommented:
I am not sure why you had groups.txt...your question says you are adding 20k users to a single group.

If you are adding all 20k users to a single group, the below command should be fast.

Get-Content C:\PowerShell\users.txt | Add-QADGroupmember GroupName -Member $_
0
 
SubsunCommented:
Try
GC C:\PowerShell\groups.txt | Add-QADGroupmember -member (GC c:\Powershell\Users.txt)

Open in new window

0
 
MilesLoganAuthor Commented:
Thank you both !!

Worked much faster ..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now