Adding Bulk Users To The Active Directory

Qasim Afzal 101 Reputation points
2022-11-20T20:48:39.53+00:00
./Bulk_Users1.psi  


           I put the "./" to indicate that it's a script  

I am adding a bunch of users from a excel spreadsheet .csv to AD from a vm admin work station. I keep getting the error:

New-ADUser : The object name has bad syntax
At C:\IT\bulk_users1.ps1:41 char:3

  • New-ADUser `
  • ~~~~~~~~~~~~
  • CategoryInfo : NotSpecified: (CN=William Jime...qafzal,DC=LOCAL:String) [New-ADUser], ADException
  • FullyQualifiedErrorId : ActiveDirectoryServer:8335,Microsoft.ActiveDirectory.Management.Commands.NewADUser

I am running the PowerShell from a domain controller as a session from the Admin Workstation because it has RSAT tools.

Not sure what is wrong..

and this is the bulk user script am running that runs its info such as name, surname from the excel spreadsheet then to the excel spreadsheet:

262275-image.png

Windows for business Windows Client for IT Pros Directory services Active Directory
Windows for business Windows Server User experience PowerShell
Windows for business Windows Server User experience Other
0 comments No comments
{count} votes

Accepted answer
  1. Rich Matheisen 47,901 Reputation points
    2022-11-20T22:24:41.093+00:00

    Your CSV is missing the comma between the first and second elements of the OU's distinguishedName in the "ou" column.

    For example, it should be "OU=Students<COMMA> . . .", not "OU=StudentsOU-CNA<COMMA> . . ."

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Rich Matheisen 47,901 Reputation points
    2022-11-20T21:08:39.417+00:00

    What is the distinguishedName of the OU in the AD? Is it the same as the distinguisheName in the "OU" column of the CSV?

    Please don't post screenshots. If you post code, use the "Code Sample" icon on the Fromat Bar (it's the 5th on from the left). If you have an error message, copy the text from the screen an post that.

    Also, you haven't shown the contents of your CSV (or at least the first few lines of it, including the header). And we have no idea what the name of the target OU is.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.