Newbie powershell learner here.
I wanted to create a script that will automate the bulk creation of our AD
I have an import csv with list of name,location,OU,etc. (I wanted to remove the OU property on the CSV file and have a script where it will automatically put in the user account on it’s OU by each location)
if (! (Get-ADUser -Filter {SamAccountName -eq $Username})) {
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 “$Username@corp.test” `
-Name “$Firstname $Lastname”`
-GivenName $Firstname `
-Surname $Lastname`
-Enabled $True `
-ChangePasswordAtLogon $True`
-DisplayName “$Lastname, $Firstname” `
-Department $Department`
-Path $OU `
-Description $description`
-state $State `
-street $Street`
-office $Office `
-EmailAddress $Email`
-city $city `
-PostalCode $Zipcode`
-Country $Country `
-Title $Jobtitle`
-Company $Company ` -AccountPassword (convertto-securestring $password -AsPlainText -Force)