Solved

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

Posted on 2013-05-16
3
640 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you both !!

Worked much faster ..
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
This article will help you understand what HashTables are and how to use them in PowerShell.
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 …

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now