?
Solved

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

Posted on 2013-05-16
3
Medium Priority
?
651 Views
Last Modified: 2013-05-17
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
Comment
Question by:MilesLogan
3 Comments
 
LVL 16

Assisted Solution

by:Rajitha Chimmani
Rajitha Chimmani earned 1000 total points
ID: 39173183
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
 
LVL 40

Accepted Solution

by:
Subsun earned 1000 total points
ID: 39173267
Try
GC C:\PowerShell\groups.txt | Add-QADGroupmember -member (GC c:\Powershell\Users.txt)

Open in new window

0
 
LVL 2

Author Closing Comment

by:MilesLogan
ID: 39176627
Thank you both !!

Worked much faster ..
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
How to deal with a specific error when using the Enable-RemoteMailbox cmdlet to create a mailbox in the cloud-based service, for an existing user in an on-premises Active Directory.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Screencast - Getting to Know the Pipeline

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question