New-AdUser from CSV combining GivenName+Surname to Name
hi
im trying create bunch of ad user via powershell. problem csv file ive got has givenname , surname , not name peramete.
thought coould 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 throws error:
new-aduser : name provided not formed account name@ 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 : name provided not formed account name,microsoft.activedirectory.manage
ment.commands.newaduser
Comments
Post a Comment