Hi
Im trying to create a bunch of ad user via powershell. The problem is that the csv file ive got only has GivenName and Surname and not a Name peramete.
The i thought i coould just combine them:
$users = Import-Csv C:\script\Users.csv | % {New-ADUser -SamAccountName $_.SamAccountName -Description $_.Description-Name "$_.GivenName $_.Surname" -GivenName $_.GivenName -Surname $_.Surname -Department $_.Department -PasswordNeverExpires $true -AccountPassword
(ConvertTo-SecureString $_.AccountPassword -AsPlainText -Force) -Enabled $true -whatif -Path "OU=Genbrugspladser,OU=Accounts,DC=XXX,DC=XXX"}
But that throws an error:
New-ADUser : The name provided is not a properly formed account nameAt line:1 char:25
+ $brugere | % {New-ADUser <<<< -SamAccountName $_.SamAccountName -Description $_.Description -Name "$_.GivenName $_.S
urname" -GivenName $_.GivenName -Surname $_.Surname -Department $_.Department -PasswordNeverExpires $true -AccountPassw
ord (ConvertTo-SecureString $_.AccountPassword -AsPlainText -Force) -Enabled $true -Path "OU=Genbrugspladser,OU=Account
s,DC=XXX,DC=XX"}
+ CategoryInfo : NotSpecified: (CN=@{SamAccount...,DC=XX,DC=XX:String) [New-ADUser], ADException
+ FullyQualifiedErrorId : The name provided is not a properly formed account name,Microsoft.ActiveDirectory.Manage
ment.Commands.NewADUser