New-ADUser -otherAttributes (acceptable range of values ERROR)

I have imported a few properties of an ADUser I want to create from a csv

DisplayName         : JT_vNext
mail                :
mailnickname        : Ha5tv9x
ProxyAddresses      :
targetaddress       :
extensionAttribute5 : MBX=25GB;TYPE=EP2D_Dumpster;

and have tried to pipe this into this bit of PS to create the user(s):

$newUsers |
     % {New-ADUser  -Credential $creds -Path 'OU=vNext,DC=amer,DC=co,DC=com'-Name $_.DisplayName -samAccountName $_.mailnickname -DisplayName $_.DisplayName -EmailAddress $_.mail `
      -OtherAttributes @{ProxyAddresses="$_.ProxyAddresses";mailnickname="$_.mailnickname";targetAddress="$_.targetaddress";extensionAttribute5="$_.extensionAttribute5"}`
       } # -Enabled $True -AccountPassword (ConvertTo-SecureString $_.Password -AsPlainText -force) -PasswordNeverExpires $True}

Error returned is:

New-ADUser : A value for the attribute was not in the acceptable range of values
At line:2 char:9

I have commented out the -Enabled True section until I can at least get some users in AD working first. NOt sure what attribute PS is balking at.


Remove the quotes around the piped object properties, as when in quotes Powershell hasn’t been given a chance to evaluate what $_.ProxyAddresses is yet.

So change:




And repeat the process for each property you have there.

If you want it in quotes, you can force evaluation by wrapping it in brackets and pre-pending a dollar sign:


Thank you Rusty…I have Users now.