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

Welcome Forums General PowerShell Q&A New-ADUser -otherAttributes (acceptable range of values ERROR)

This topic contains 2 replies, has 2 voices, and was last updated by

2 years, 6 months ago.

  • Author
  • #53988

    Points: 71
    Rank: Member

    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.


  • #53989

    Points: 1
    Rank: Member

    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:

    • #53993

      Points: 71
      Rank: Member

      Thank you Rusty....I have Users now.

The topic ‘New-ADUser -otherAttributes (acceptable range of values ERROR)’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort