Solved

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

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
This article runs through the process of deploying a single EXE application selectively to a group of user.
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

808 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