import AD from .csv RRS feed

  • Question

  • for importing in a specific OU in AD(2012r2), i am using the following ps code:

    Import-Csv c:\export.csv | New-ADUser -Enabled $True -Path 'OU=company,OU=IT,DC=ad.mycompany,DC=local' -AccountPassword (ConvertTo-SecureString Pass01 -AsPlainText -force)

    i have put the export.csv on the root, because i dont know the path to the desktop in Powershell

    i am using ISE, am logged in as domain admin at the dc

    but when doing this, i am getting the following error:


    New-ADUser : The server is unwilling to process the request
    At C:\Users\Administrator\Desktop\import.ps1:1 char:28
    + Import-Csv c:\export.csv | New-ADUser -Enabled $True -Path 'OU=company,OU=IT ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (CN=Jean Johnson...pany,DC=local:String) [New-ADUser], ADException
        + FullyQualifiedErrorId : ActiveDirectoryServer:0,Microsoft.ActiveDirectory.Management.Commands.NewADUser

    New-ADUser : The server is unwilling to process the request
    At C:\Users\Administrator\Desktop\import.ps1:1 char:28
    + Import-Csv c:\export.csv | New-ADUser -Enabled $True -Path 'OU=company,OU=IT ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (CN=Jon Smits,OU...pany,DC=local:String) [New-ADUser], ADException
        + FullyQualifiedErrorId : ActiveDirectoryServer:0,Microsoft.ActiveDirectory.Management.Commands.NewADUser

    anyone who can help me with this, what am i doing wrong? When trying to import/export content into a AD, most of the time i only find very large scripts i dont understand. Thats why i am doing it this why.

    also, the next step would be exporting and importing groups

    Sunday, May 19, 2019 10:50 AM

All replies

  • Bad or missing data in your Csv.  The CSV columns must have exact names and all columns must have values.  You cannot import multi-valued attributes and all columns must have an associated named CmdLet parameter.


    Sunday, May 19, 2019 10:55 AM
  • many thanks for your reply.

    the csv looks like this:

    Name,Type,Description,First Name,Last Name,Display Name
    John Johnson,User,programmer,John,Johnson,John Johnson

    i dont see any missing info

    Sunday, May 19, 2019 11:09 AM
  • ok, noticed i am missing the username

    mmm, that didnt do the trick.

    i changed the csv into this(downlaoded one):

    firstname middleInitial lastname username email streetaddress city zipcode state country description office department password telephone jobtitle company ou
    Rick M Sanchez rsanchez 1234 Grove St Seattle 98101 WA United States C137 Research Ch@ng3Me! 206-876-5309 Interdimensional Traveler mycompany CN=mycompany,CN=IT,DC=ad,DC=mycompany,DC=local

    am getting this error:

    New-ADUser : The input object cannot be bound because it did not contain the information required to bind all mandatory parameters:  Name
    At C:\Users\Administrator\Desktop\import.ps1:1 char:28
    + Import-Csv c:\export.csv | New-ADUser -Enabled $True -Path 'OU=mycompany,OU=IT ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (@{firstname=Ric...lting,DC=local}:PSObject) [New-ADUser], ParameterBindingException
        + FullyQualifiedErrorId : InputObjectMissingMandatory,Microsoft.ActiveDirectory.Management.Commands.NewADUser

    • Edited by enlil Sunday, May 19, 2019 11:16 AM
    Sunday, May 19, 2019 11:10 AM
  • The headers must be an exact match to all parameters as used by the CmdLet.

    "Display Name" has a space which is not what it is in the CmdLet.  Almost none of your CSV headers are correct.  They must be an exact match.

    help New-AdUser -online


    • Edited by jrv Sunday, May 19, 2019 12:04 PM
    Sunday, May 19, 2019 12:03 PM
  • but when using the downloaded csv(pitty i cannot add an attachment), i dont have any spaces and i still get the same error.
    Sunday, May 19, 2019 12:08 PM
  • You have to fix all of the headers. They are almost all wrong.  There is not firstname/lastname in AD.  It is GivenName and Surname.  Please read the help carefully and review all of the parameters.


    Sunday, May 19, 2019 12:11 PM
  • ok, that is interesting. i downloaded several .csv from tutorial that used those headers.

    Can you advice a tutorial that shows me how to import users from a csv in a specific OU? Cause every tutorial i found isnt working.

    Sunday, May 19, 2019 12:30 PM
  • There is no tutorial like you claim.  You must have found a bogus site.  There are many that claim they know PS but most are fakes just to get you to the advertising.

    Here is an MS tutorial that will teach you basic PowerShell which is where you have to start.

          Microsoft Virtual     Academy - Getting Started with Microsoft PowerShell


    Sunday, May 19, 2019 12:35 PM