locked
New-ADUser : A value for the attribute was not in the acceptable range of values RRS feed

  • Question

  • When importing users to AD using Powershell, got an error message
     New-ADUser : A value for the attribute was not in the acceptable range of values

     New-ADUser : A value for the attribute was not in the acceptable range of values
     At line:4 char:5
     +     New-ADUser -Name $temp_user.Name `
     +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         + CategoryInfo          : NotSpecified: (CN=Ray Johnson,...C=renevo,DC=int:String) [New-ADUser], ADException
         + FullyQualifiedErrorId : A value for the attribute was not in the acceptable range of values,Microsoft.ActiveDirectory.Management.Commands.NewADUser
     
     New-ADUser : A value for the attribute was not in the acceptable range of values
     At line:4 char:5
     +     New-ADUser -Name $temp_user.Name `
     +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         + CategoryInfo          : NotSpecified: (CN=Scott Harris...C=renevo,DC=int:String) [New-ADUser], ADException
         + FullyQualifiedErrorId : A value for the attribute was not in the acceptable range of values,Microsoft.ActiveDirectory.Management.Commands.NewADUser

     here is the script.

    $temp_users=Import-Csv -Path Z:\C\Temp\test_users.csv
     foreach($temp_user in $temp_users)
     {
         New-ADUser -Name $temp_user.Name `
             -DisplayName $temp_user.DisplayName `
             -GivenName $temp_user.GivenName `
             -Initials $temp_user.Initials `
             -Surname $temp_user.Surname `
             -EmployeeID $temp_user.EmployeeID `
             -EmployeeNumber $temp_user.EmployeeNumber `
             -SamAccountName $temp_user.SamAccountName `
             -UserPrincipalName $temp_user.UserPrincipalName `
             -Department $temp_user.Department `
             -Company $temp_user.Company `
             -Office $temp_user.Office `
             -StreetAddress $temp_user.StreetAddress `
             -Country $temp_user.Country `
             -AccountPassword (ConvertTo-SecureString $temp_user.AccountPassword -AsPlainText -force) `
             -Path $temp_user.Path `
             -AuthType 0 `
             -PasswordNotRequired $false `
             -CannotChangePassword $false `
             -ChangePasswordAtLogon $true `
            -Enabled $true `
             -PassThru
     }
    
    

     Here is the sample data from a CSV:

    Name      DisplayName      GivenName      Initials      Surname      EmployeeID      EmployeeNumber      SamAccountName      UserPrincipalName      Department      Company      Office      StreetAddress      Country      AccountPassword      Path
     Ray Johnson      Ray A Johnson      Ray      A      Johnson      EMPa00001      HRa0001      EMPa00001      EMPa00001@RENEVO.INT      Admin/Secretarial      1FB Support Services      Ross Street      Ross Street      India      Dthoiwky@001      OU=Office Users,OU=Users,OU=IN Hyderabad,DC=renevo,DC=int
     Scott Harris      Scott C Harris      Scott      C      Harris      EMPa00002      HRa0002      EMPa00002      EMPa00002@RENEVO.INT      Customer Service/ Call Centre/ BPO      24/7 Customer      Emeral Dreams Drive      Emeral Dreams Drive      India      Dthoiwky@001      OU=Office Users,OU=Users,OU=IN Delhi,DC=renevo,DC=I


    Thx, Ganga Raju


    • Edited by jrv Tuesday, August 15, 2017 11:34 PM Fixed bad post
    Tuesday, August 15, 2017 11:23 PM

All replies

  • I fixed you post a bit.   Do not post text copied from a web page.

    Your CSV is unreadable. Copy the text from the file and post as text.

    There is no way to know the issue.  Try outputting the row identifier that causes the error.  Mostly this is due to a bad CSV file.


    \_(ツ)_/


    • Edited by jrv Tuesday, August 15, 2017 11:40 PM
    Tuesday, August 15, 2017 11:36 PM
  • You csv seems to lack the comma delimiters separating the field values. That may be because of how you posted it. But the values for your field labeled Path have embedded commas, so they must be quoted in a csv.

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Wednesday, August 16, 2017 12:09 AM
  • I am sorry, I have copied the csv from the excel and pasted it here directly.. 
    let me get the same CSV from a notepad. 

    I suppose the csv is formatted correctly.  - please advise where exactly I am getting this wrong. or if I am missing something.. 

    Name,DisplayName,GivenName,Initials,Surname,EmployeeID,EmployeeNumber,SamAccountName,UserPrincipalName,Department,Company,Office,StreetAddress,Country,AccountPassword,Path
    Ray Johnson,Ray A Johnson,Ray,A,Johnson,EMPa00001,HRa0001,EMPa00001,EMPa00001@RENEVO.INT,Admin/Secretarial,1FB Support Services,Ross Street,Ross Street,India,Dthoiwky@001,"OU=Office Users,OU=Users,OU=IN Hyderabad,DC=renevo,DC=int"
    Scott Harris,Scott C Harris,Scott,C,Harris,EMPa00002,HRa0002,EMPa00002,EMPa00002@RENEVO.INT,Customer Service/ Call Centre/ BPO,24/7 Customer,Emeral Dreams Drive,Emeral Dreams Drive,India,Dthoiwky@001,"OU=Office Users,OU=Users,OU=IN Delhi,DC=renevo,DC=int"
    Anna Johnson,Anna J Johnson,Anna,J,Johnson,EMPa00003,HRa0003,EMPa00003,EMPa00003@RENEVO.INT,Finance & Accounts,3 Global Services,Park Street,Park Street,India,Dthoiwky@001,"OU=Office Users,OU=Users,OU=IN Kolkatta,DC=renevo,DC=int"


    Thx, Ganga Raju



    • Edited by Ganga Raju Wednesday, August 16, 2017 2:51 AM
    Wednesday, August 16, 2017 2:50 AM
  • You still have to capture the record that is causing you the issue.  We cannot run your system for you. 


    \_(ツ)_/



    • Edited by jrv Wednesday, August 16, 2017 2:53 AM
    Wednesday, August 16, 2017 2:52 AM
  • sure, I will try to edit the path and record the things as  you described. and will let you know the result. 


    Thx, Raju

    Wednesday, August 16, 2017 2:58 AM
  • This would be easier to understand and manage.

    ImportCsv Path Z:\C\Temp\test_users.csv |
    	ForEach-Object{
    		$props = @{
    			Name = $_.Name
    			DisplayName = $_.DisplayName
    			GivenName = $_.GivenName
    			Initials = $_.Initials
    			Surname = $_.Surname
    			EmployeeID = $_.EmployeeID
    			EmployeeNumber = $_.EmployeeNumber
    			SamAccountName = $_.SamAccountName
    			UserPrincipalName = $_.UserPrincipalName
    			Department = $_.Department
    			Company = $_.Company
    			Office = $_.Office
    			StreetAddress = $_.StreetAddress
    			Country = $_.Country
    			AccountPassword = ConvertTo-SecureString $_.AccountPassword -AsPlainText -force
    			Path = $_.Path
    			PasswordNotRequired = $false
    			CannotChangePassword = $false
    			ChangePasswordAtLogon = $true
    			Enabled = $true
    		}
    		NewADUser @props -WhatIf
    	}
    


    \_(ツ)_/

    Wednesday, August 16, 2017 3:02 AM
  • The -Country parameter assigns the attribute with lDAPDisplayName "c", which is the two letter abbreviation. I believe the value assigned to -Country should be "IN" instead of "India". See the help for New-ADUser.

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    • Proposed as answer by I.T Delinquent Wednesday, August 16, 2017 2:29 PM
    Wednesday, August 16, 2017 6:16 AM