Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

How to speed up powershell script that utilizes .csv files

$
0
0

I have used this script several times to bulk import users into AD, but now it seems to slow down considerably.  It works fine as the information is correct.  I am typically importing around 300-400 users.  Is there a way to speed up my bulk import of AD users?  Example of script below:

  cd \Create-Users
 
 
 Import-Module *active*

 
 
 $adusers = Import-csv c:\Create-Users\adusers.csv
 
 
 foreach ($user in $adusers)
 
   {
 
   $username = $user.username
 
   $password = $user.password
 
   $firstname = $user.firstname
    
   $userprinicpalname = $user.firstname + "@xxx.xxx.com"   
   
   $description = $user.description

   new-aduser -samaccountname $username -UserPrincipalName $userprinicpalname -DisplayName $firstname  -Description      $description -name $firstname -givenname $firstname -enabled $true -accountpassword (convertto-securestring $password -asplaintext -force) -PasswordNeverExpires $true 

   } 


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>