Quantcast
Channel: /r/powershell – How to Code .NET
Viewing all articles
Browse latest Browse all 8793

AD user bulk creation with csv

$
0
0

So ive tried a bunch of different scripts to create bulk users from a .csv file. All of the have had on problem or other, and im below beginner level, so i have no idea what to do. I get the error “New-ADUser : Cannot validate argument on parameter ‘Name’. The argument is null or empty.” This is my code:

 Import-CSV -Delimiter ";" c:csvfolderusers1.csv | foreach-object { $userprincipalname =$_.SamAccountName + "@test.net" New-ADUser -SamAccountName $_.SamAccountName -UserPrincipalName @userprincipalname -name $_.name -DisplayName $_.name -GivenName $_.cn -Surname $_.sn -path "CN=Users,DC=test,DC=net" -AccountPassword (ConvertTo-SecureString "ADTest&123" -AsPlainText -force) -Enable $True -PasswordNeverExpires $True -PassThru } 

This is the csv file:
http://i.imgur.com/5DA0TLO.png

This is the error message:

 New-ADUser : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. > At C:UsersAdministratorDocumentsUntitled2.ps1:3 char:90 > + ... ipalname -name $_.name -DisplayName $_.name -GivenName $_.cn -Surname $_.sn -pat ... > + ~~~~~~~ > + CategoryInfo : InvalidData: (:) [New-ADUser], ParameterBindingValidationException > + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.NewADUser > > New-ADUser : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. > At C:UsersAdministratorDocumentsUntitled2.ps1:3 char:90 > + ... ipalname -name $_.name -DisplayName $_.name -GivenName $_.cn -Surname $_.sn -pat ... > + ~~~~~~~ > + CategoryInfo : InvalidData: (:) [New-ADUser], ParameterBindingValidationException > + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.NewADUser > > New-ADUser : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again. > At C:UsersAdministratorDocumentsUntitled2.ps1:3 char:90 > + ... ipalname -name $_.name -DisplayName $_.name -GivenName $_.cn -Surname $_.sn -pat ... > + ~~~~~~~ > + CategoryInfo : InvalidData: (:) [New-ADUser], ParameterBindingValidationException > + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.ActiveDirectory.Management.Commands.NewADUser 

Any help would be very much appreciated!

submitted by /u/Leiox
[link] [comments]

The post AD user bulk creation with csv appeared first on How to Code .NET.


Viewing all articles
Browse latest Browse all 8793

Trending Articles