Can't seem to find how to import a multi-valued attribute into Active Directory, specifically the otheripphone field. I was able to successfully export the first value in that array to a CSV, but nothing works for import:
Export command in powershell (exports 1st value in the array of the ipphonefield)
get-aduser -properties samaccountname,mail,physicaldeliveryofficename,ipphone,otheripphone,enabled | select samaccountname,mail,physicaldeliveryofficename,@{L='otheripphone'; E={$_.otheripphone[0]}},enabled | export-csv "C:\Vidyo_AD_User_export.csv"
Import script(csv file only contains samaccountname and otheripphone field)
$users = Import-Csv C:\test.csv
foreach ($user in $users) {
Get-ADUser -Filter "samaccountname '$($user.samaccountname)'" |
Set-ADUser -add @{otheripphone=$($user.otheripphone)}
}
I get the following error from the script
Get-ADUser : Error parsing query: 'samacc
ountname 'import.test'' Error Message:
'syntax error' at position: '16'.
At C:\test.ps1:22 char:12
+ Get-ADUser <<<< -Filter "samaccountname '$($user.samaccountname)'" |
+ CategoryInfo : ParserError: (:) [Get-ADUser], ADFilterParsingEx
ception
+ FullyQualifiedErrorId : Error parsing query: 'samaccountname 'import.tes
t'' Error Message: 'syntax error' at position: '16'.,Microsoft.ActiveDirec
tory.Management.Commands.GetADUser