How to create Multiple Users in Active Directory Users and Computers using PowerShell Script

KELVGLOBAL ICT
KELVGLOBAL ICT
3.2 هزار بار بازدید - 2 سال پیش - If are you trying to
If are you trying to create multiple users in Active Directory Users and computers, it will not be a best practice to create them manually. The best method is to use powershell script. In this video, we are going to learn how to create multiple users in Active directory using powershell script.

#Enter a path to your import CSV file
$ADUsers = Import-csv C:\temp\NewUsers1.csv

foreach ($User in $ADUsers)
{

      $Username    = $User.username
      $Password    = $User.password
      $Firstname   = $User.firstname
      $Lastname    = $User.lastname
   $Department = $User.department
      $OU           = $User.ou

      #Check if the user account already exists in AD
      if (Get-ADUser -F {SamAccountName -eq $Username})
      {
              #If user does exist, output a warning message
              Write-Warning "A user account $Username has already exist in Active Directory."
      }
      else
      {
             #If a user does not exist then create a new user account
         
       #Account will be created in the OU listed in the $OU variable in the CSV file; don’t forget to change the domain name in the"-UserPrincipalName" variable
             New-ADUser `
           -SamAccountName $Username `
           -UserPrincipalName "[email protected]" `
           -Name "$Firstname $Lastname" `
           -GivenName $Firstname `
           -Surname $Lastname `
           -Enabled $True `
           -ChangePasswordAtLogon $True `
           -DisplayName "$Lastname, $Firstname" `
           -Department $Department `
           -Path $OU `
           -AccountPassword (convertto-securestring $Password -AsPlainText -Force)

      }
}

NewUsers1.csv File

firstname,middleInitial,lastname,username,email,streetaddress,city,zipcode,state,country,department,password,telephone,jobtitle,company,ou
Festus,,Rond,festus.rond,,,,,,,,Paswd@1930,,,,"OU=Users,OU=Rome,OU=KELVGLOBAL,DC=KELVGLOBAL,DC=COM"
Silvester,,Bri,silvester.brik,,,,,,,,Paswd@1930,,,,"OU=Users,OU=Rome,OU=KELVGLOBAL,DC=KELVGLOBAL,DC=COM"
Rom,,Roo,rom.roo,,,,,,,,Paswd@1930,,,,"OU=Users,OU=Rome,OU=KELVGLOBAL,DC=KELVGLOBAL,DC=COM"
Tim,,Track,tim.track,,,,,,,,Paswd@1930,,,,"OU=Users,OU=Rome,OU=KELVGLOBAL,DC=KELVGLOBAL,DC=COM"
Fred,,Solo,fred.solo,,,,,,,,Paswd@1930,,,,"OU=Users,OU=Rome,OU=KELVGLOBAL,DC=KELVGLOBAL,DC=COM"

Unlock Your Potential with Udemy! Mastering IT Systems Administration & Azure Cloud Engineering: https://www.udemy.com/course/masterin...

Are you ready to dive into the world of IT System Administration and Azure Cloud Engineering? Look no further! Udemy presents an exclusive course designed to elevate your skills and empower your career journey.

Support My Effort with a Coffee!

If you've found my assistance helpful and would like to show your appreciation, you can support my efforts by buying me a coffee. Your generosity helps fuel my commitment to providing valuable assistance to users like you.

How to Support:
If you're inclined to buy me a coffee, you can do so through PayPal using the following link:

Buy Me a Coffee via PayPal: https://paypal.me/kelvglobalict

Your contribution is greatly appreciated and goes a long way in supporting the ongoing development of helpful resources and assistance. Thank you for your support!

PayPal Link: https://paypal.me/kelvglobalict:  


Stay Connected with Me!

Let's stay connected on social media and continue our journey together. Here are the various platforms where you can find me:

📱 TikTok: [Follow me for one-on-one chat] TikTok: kelvglobalict

🖥️ Facebook Group: [Join the Windows 11 Facebook Group] Facebook: 266762851455036

📘 Facebook: [Connect on Facebook] Facebook: kelvglobalict

📸 Instagram: [Follow me on Instagram] Instagram: kelvinjohnson274

🔗 LinkedIn: [Connect with me on LinkedIn] LinkedIn: kelvin-johnson-110334111

🐦 Twitter: [Follow me on Twitter] Twitter: kejocomputers

🌐 Website: [Visit my website] https://www.kelvglobal.com

💰 PayPal Donation: [Support my efforts with a donation] https://paypal.me/kelvglobalict

📧 Email: [Get in touch via email] https://kelvglobal.com/contact/

🎥 YouTube: [Subscribe to my YouTube channel] kelvinjohnson-ict

Let's connect and continue to share valuable insights and resources. Looking forward to engaging with you across these platforms!

Ensure to click on the respective links to connect with me on each platform.


#kelvglobalict #powershellscript #activedirectory
2 سال پیش در تاریخ 1401/10/25 منتشر شده است.
3,256 بـار بازدید شده
... بیشتر