I'm trying to import users into AD, using a PowerShell script, and a CSV.
Here's my script (with names removed):
$pass = ConvertTo-SecureString "passwordhere" -AsPlainText -Force
Import-Csv .\adimport.csv | New-ADUser -AccountPassword $pass -Enabled $true -ChangePasswordAtLogon $true
Get-ADUser -Filter * -SearchBase 'OU=<ouname>,OU=<ouname>,OU=<ouname>,OU=<ouname>,DC=<name>,DC=<name>,DC=<name>,DC=<name>' -Properties userPrincipalName | foreach { Set-ADUser $_ -UserPrincipalName "$($_.samaccountname)@<domainname>"}
And here's how my CSV looks:
Name Username SamAccountName GivenName Surname DisplayName Description Path Enabled Postalcode StreetAddress City Title Office Company extensionAttribute2 officephone
Everything works fine, the users are imported (into the correct OU), and all the information is updated, apart from extensionAttribute2.
Does anyone have know what I would need to change to get extensionAttribute2 in AD to import the information under extensionAttribute2, from the CSV, when running the script?
If anyone needs any more information, let me know.
Any help would be appreciated. Thanks.