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

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Jeff Taylor Jeff Taylor 2 months, 3 weeks ago.

  • Author
    Posts
  • #53988
    Profile photo of Jeff Taylor
    Jeff Taylor
    Participant

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

    DisplayName         : JT_vNext
    mail                : JT_vNext@co.com
    mailnickname        : Ha5tv9x
    ProxyAddresses      : SMTP:J_T_vNext@co.com
    targetaddress       : smtp:Ha5tv9x@mgd.co.com
    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.

    Thanks

  • #53989
    Profile photo of 84rusty .
    84rusty .
    Participant

    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:

    ProxyAddresses="$_.ProxyAddresses"
    

    To:

    ProxyAddresses=$_.ProxyAddresses
    

    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:

    ProxyAddresses="$($_.ProxyAddresses)"
    
    • This reply was modified 2 months, 3 weeks ago by Profile photo of 84rusty . 84rusty ..
    • #53993
      Profile photo of Jeff Taylor
      Jeff Taylor
      Participant

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

You must be logged in to reply to this topic.