Solved

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

Posted on 2013-05-16
3
645 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 250 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 250 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

This article explains the steps required to use the default Photos screensaver to display branding/corporate images
A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
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 antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

730 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