Link to home
Get AccessLog in
Avatar of mfishco
mfishcoFlag for United States of America

asked on

Importing Users via CSV


I'm making a mistake somewhere in the process of reading a CSV containing user records and using the New-ADUser cmdlet to add them to AD.  I'm running these commands on a patched 2008R2 domain controller.

the csv file is as follows (also attached):

LDAP://TL,TL,testuser7,testuser7,,Test,User,"Test User 7",testuser7,Address,Greenwood Village,CO,80111,303-555-5555,303-555-5555,303-555-5555,303-555-5555,,Toady,Custodial,Denver,This is a notes field,abc123456@@@

Open in new window

the script is:

Import-Csv .\test_ad_users2.csv
foreach-object {
	#$password = $_.tempPassword
	New-ADUser `
		-SamAccountName $_.SamAccountName `
		-UserPrincipalName $_.userprinicpalname `
		-DisplayName $ `
		-Name $ `
		-GivenName $ `
		-SurName $ `
		-Department $_.Department `
		-Path "OU=ImportTest,DC=ifs,DC=local" `
		-AccountPassword (ConvertTo-SecureString "abc123456@@@" -AsPlainText -force) `
		-Enabled $True `
		-PasswordNeverExpires $True `
		-PassThru `

Open in new window

I'm getting the error:

New-ADUser : Cannot validate argument on parameter 'Name'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.
At C:\adimport\ADMUserCreation.ps1:10 char:8
+         -Name <<<<  $ `
    + CategoryInfo          : InvalidData: (:) [New-ADUser], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.NewADUser

I've tried everything I can think of to understand what this message means in my context.  If I run the following I get the name attribute "testuser7" returned:

import-csv c:\adimport\test_ad_users.csv | foreach-object { $}

Open in new window

that tells me the error isn't what it seems to be.  Anyone have any ideas?  Any help would be appreciated.

Thank you.

Avatar of SubSun
Flag of India image

Link to home
This content is only available to members.
To access this content, you must be a member of Experts Exchange.
Get Access
Avatar of mfishco


Thank you!  Such a small thing taking so much time and energy...