Create AD Accounts in Bulk with Powershell
Manual creation of Active Directory accounts is definitely a thing of the past and in this post i will show you how you can save hours of time with a simple csv file and a Powershell script.
Firstly you will need to compose a similar csv file to the one below and enter the specific details you need. Also pay close attention to the path section as this can easily cause issues. To find the Active Directory Path of the desired OU you can use the command below, this can then be pasted into the csv file.
Get-ADOrganizationalUnit -Filter ‘Name -like “ou name”‘ | select ‘distinguishedname’
CSV File
Once you have created the csv file and saved it to an easily accessible location, paste the below Powershell script into Powershell Ise (link in sources). This script will then take the details from the csv file and create User Accounts based on those details.
import-module activedirectory
Import-Csv "C:\path\users.csv" | ForEach-Object {
$userPrincipal = $."samAccountName" + "@yourdomain.com"
$password = ConvertTo-SecureString -AsPlainText $."password" -force
New-ADUser -Name $_."user"
-Path $."path" -SamAccountName $_."samaccountname"
-DisplayName $."Displayname" -Givenname $_."name"
-Surname $."surname" -UserPrincipalName $userPrincinpal
-AccountPassword $password -ChangePasswordAtLogon $true
-Enabled $true `
-Description $."description"
}
The only thing you need to change from this script is the path to the csv file on line 2 and the domain name on line 3. Once it is ready you can run the script as administrator in Powershell Ise and then all the accounts will be created, Great Time Saver !
sources
https://docs.microsoft.com/en-us/powershell/scripting/getting-started/fundamental/windows-powershell-integrated-scripting-environment–ise-?view=powershell-6
Leave Create AD Accounts in Bulk with Powershell to:
Read more #technology posts
Best Posts From TechTutorials101
We have not curated any of danielmbutler's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From TechTutorials101
- Pilgrim Challenge 50k – North Downs Ultra Marathon
- First Experience of a 45 mile UltraMarathon
- What I learned in my first year pursuing endurance
- Sysadmin Tools Showcase: TreeSize
- How to Download, set up and create your first VM in Virtual Box
- How To Install Applications Silently
- Create AD Accounts in Bulk with Powershell
- How To Configure Fine Grained Password Policy on Windows Server 2012
- How To start Earning GridCoin With GRC pool
- Bringing Tech Articles To SteemIt