Trying Create Script Bulk Add Users Test Active Directory Environment Everything Loads Cor Q34327878

I am trying to create a script to bulk add users in a testActive Directory environment. Everything loads correctly except theManager column. This won’t load into the organization section of auser’s profile at all. Here is my script and CSV I’m using.

# Import active directory module for running AD cmdlets
Import-Module activedirectory
  
#Store the data from ADUsers.csv in the $ADUsers variable
$ADUsers = Import-csv ‘C:UsersAdminDesktopSuccessful ScriptSampleAD CSV for Import.csv’

#Loop through each row containing user details in the CSVfile
foreach ($User in $ADUsers)
{
   #Read user data from each field in each row and assignthe data to a variable as below
      
   $FirstName    = $User.FirstName
   $LastName    = $User.LastName
   $DisplayName    = $User.DisplayName
   $Lastname    = $User.Lastname
   $OU        = $User.OU #Thisfield refers to the OU the user account is to be created in
   $EmailAddress     =$User.EmailAddress
   $Username    = $User.Username
   $Password     = $User.Password
   $JobTitle     = $User.JobTitle
   $Department     =$User.Department
   $Company     = $User.Company
   $Description     =$User.Description
   $Telephone     = $User.Telephone
   $Manager     = $User.Manager

   #Check to see if the user already exists inAD
   if (Get-ADUser -F {SamAccountName -eq$Username})
   {
       #If user does exist, give awarning
       Write-Warning “A user account withusername $Username already exist in Active Directory.”
   }
   else
   {
       #User does not exist then proceedto create the new user account
      
#Account will be created in the OU provided by the $OU variableread from the CSV file
       New-ADUser `
-SamAccountName $Username `
-UserPrincipalName “$Username@ADTest.com” `
-Name “$FirstName $LastName” `
-GivenName $FirstName `
-Surname $LastName `
-Enabled $True `
-DisplayName “$LastName, $FirstName” `
-Path $OU `
-Description $Description `
-Company $Company `
-EmailAddress $EmailAddress `
-Title $JobTitle `
-OfficePhone $Telephone `
-Department $Department `
-AccountPassword (convertto-securestring $Password -AsPlainText-Force) -ChangePasswordAtLogon $True
  
   }
}

Department Company Description Telephone Manager CEO OU Username Password ThKern AD Tes EMP ID 60133 912-250 343 AD Test Board OU-Users,OU-r AD Test EMP ID 33269 205-794-966 Kern, Thomas OU-Users,OU AD Test EMPID 82272 203-342-375 Kern, Thomas OU-Users,OUr JobTitle FirstName LastName DisplayName Thomas Kern EailAddress -User,oua ThKe60133 CEO Chief Executive Office officer SEc elma Jack Jackson, VelmaVelackson@ADTest.comVelackson Vela33269 CIO Chief Information Officer ITS Peggy McKenzie McKenzie, Peggy PeMcKenzie@ADTest.comPeMckenzie PeMc82272 CSO Chief Security Officer Kern, Thomas ThKern@ADTest.com

I can send the actual CSV file if needed.

Department Company Description Telephone Manager CEO OU Username Password ThKern AD Tes EMP ID 60133 912-250 343 AD Test Board OU-Users,OU-r AD Test EMP ID 33269 205-794-966 Kern, Thomas OU-Users,OU AD Test EMPID 82272 203-342-375 Kern, Thomas OU-Users,OUr JobTitle FirstName LastName DisplayName Thomas Kern EailAddress -User,oua ThKe60133 CEO Chief Executive Office officer SEc elma Jack Jackson, VelmaVelackson@ADTest.comVelackson Vela33269 CIO Chief Information Officer ITS Peggy McKenzie McKenzie, Peggy PeMcKenzie@ADTest.comPeMckenzie PeMc82272 CSO Chief Security Officer Kern, Thomas ThKern@ADTest.com Show transcribed image text

“We Offer Paper Writing Services on all Disciplines, Make an Order Now and we will be Glad to Help”

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.