I have a simple user creation script that works great except for extensionattributes. I’m having issues with the autopopulate/translation of the extenstion attributes. I’m familiar with set-aduser and the process of adding extension attributes but with New-aduser it needs “-otherattributes” to define the custom attribute. Which works fine if I manually add it, but wont work in my translation.(or I can’t get the syntax correct) How do I properly incorporate the ability to pull custom/extension attributes straight from the csv?
import-csv “.\newusers.csv” | Select-Object Title, Department, City, State, Office, EmployeeID,DBRMember,Manager?,Contractor,VIP,`
@{name=‘name’;e={($.‘First Name’+’ '+$.‘Last Name’)}},
@{name=‘samaccountname’;e={($.‘First Name’.substring(0,1)+$.‘Last Name’).tolower()}},
@{name=‘UserPrincipalName’;e={($.‘First Name’.substring(0,1)+$.‘Last Name’).toLower()+“@company.com”}},
@{name=‘displayname’;e={$.‘First Name’+’ '+$.‘Last Name’}},
@{name=‘givenname’;e={$.‘First Name’}},
@{name=‘surname’;e={$.‘Last Name’}},
@{name=‘path’;e={‘Ou=Test,OU=IT,OU=company,DC=company,DC=com’}},
@{name=‘extensionAttribute1’;e={$.‘DBRMember’}},
@{name=‘extensionAttribute2’;e={$.‘Manager?’}},
@{name=‘extensionAttribute3’;e={$.‘Contractor’}},
@{name=‘extensionAttribute4’;e={$.‘VIP’}}|
Out-GridView
For example, this works when manually specified
New-Aduser -ChangePasswordAtLogon $true -Enabled $true -AccountPassword $(ConvertTo-Securestring ‘P@$$word’ -AsPlainText -force)`
-Description "Test User Creation By Script"`
-HomeDrive ‘h:’ `
-HomeDirectory "\company\dfs\users%username%"`
-Company “Company, Inc” `
-StreetAddress “1234 Innovation Way” `
-PostalCode "12345"`
#-OtherAttributes @{extensionAttribute1=“TEST”;extensionAttribute2= “TEST2”; extensionattribute3=“Test3”; extensionattribute4=“Test4”}